[From nobody Mon Mar 25 16:16:22 2013
Return-path: &lt;owner-erlang-questions@erlang.org&gt;
Path: news.gmane.org!not-for-mail
X-Trace: sea.gmane.org 1123212598 11573 80.91.229.2 (5 Aug 2005 03:29:58 GMT)
Date: Thu, 04 Aug 2005 09:42:41 -0400
From: Serge Aleynikov &lt;serge@hq.idt.net&gt;
Subject: Re: emulator exit
In-reply-to: &lt;42F20E8F.2060103@mobilearts.se&gt;
Approved: news@gmane.org
Cc: Erlang Questions &lt;erlang-questions@erlang.org&gt;
Message-id: &lt;42F21B51.5080902@hq.idt.net&gt;
Organization: IDT Corp
X-Complaints-to: usenet@sea.gmane.org
MIME-version: 1.0
Content-type: text/plain; charset=ISO-8859-1; format=flowed
Content-transfer-encoding: 7BIT
NNTP-posting-date: Fri, 5 Aug 2005 03:29:58 +0000 (UTC)
X-Accept-Language: en-us, en
Precedence: bulk
Original-X-From: owner-erlang-questions@erlang.org Fri Aug 05 05:29:49 2005
Original-Received: from mail-relay.eunet.no ([193.71.71.242])	by ciao.gmane.org
 with esmtp (Exim 4.43)	id 1E0stS-0007TT-KM	for
 gcleg-erlang-questions@gmane.org; Fri, 05 Aug 2005 05:29:10 +0200
Original-Received: from hades.cslab.ericsson.net (hades.cslab.ericsson.net
 [193.180.168.23])	by mail-relay.eunet.no (8.13.1/8.13.1/GN) with ESMTP id
 j74DqpQj077498	for &lt;gcleg-erlang-questions@gmane.org&gt;; Thu,
 4 Aug 2005 15:52:51 +0200 (CEST)	(envelope-from
 owner-erlang-questions@erlang.org)
Original-Received: (from majordom@localhost)	by hades.cslab.ericsson.net
 (8.10.0/8.10.0/hades-1.2) id j74DiEc11641	for erlang-questions-outgoing; Thu,
 4 Aug 2005 15:44:14 +0200 (CEST)
Original-Received: from mail.corp.idt.net (mail.corp.idt.net [169.132.25.53])
 by hades.cslab.ericsson.net (8.10.0/8.10.0/hades-1.2) with
 ESMTP id
 j74DiAv11636	for &lt;erlang-questions@erlang.org&gt;; Thu,
 4 Aug 2005 15:44:11 +0200 (CEST)
Original-Received: from [169.132.9.113] (account saleyn HELO [169.132.9.113])
 by mail.corp.idt.net (CommuniGate Pro SMTP 4.2) with ESMTP
 id 110590323; Thu, 04 Aug 2005 09:44:04 -0400
Original-To: Rikard Johansson &lt;rikard.johansson@mobilearts.se&gt;
Original-Sender: owner-erlang-questions@erlang.org
X-Report-Spam: http://spam.gmane.org/gmane.comp.lang.erlang.general:11216
Newsgroups: gmane.comp.lang.erlang.general
NNTP-posting-host: main.gmane.org
References: &lt;42F2050C.3030201@hq.idt.net&gt; &lt;42F20E8F.2060103@mobilearts.se&gt;
User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711)
Xref: news.gmane.org gmane.comp.lang.erlang.general:11216

Thanks, I seemed to have missed this one in the docs.  Is the proper way 
of shutting down the emulator cleanly with an exit code the following?

1&gt; F = fun(N) -&gt; init:stop(), erlang:halt(N) end.
#Fun&lt;erl_eval.20.102880425&gt;
2&gt; F(100).
~~&gt;echo $?
100

Is it guaranteed that the erlang:halt/1 call will be executed before the 
emulator exits as a result of the init:stop() call?

Serge

Rikard Johansson wrote:
&gt; 
&gt; Actually there is a erlang:halt/1 which take the wanted exit code 
&gt; (integer()) as argument.
&gt; 
&gt; 1&gt; erlang:halt(11).
&gt; [rikard@tt rikard]$ echo $?
&gt; 11
&gt; 
&gt; Best regards,
&gt; 
&gt; /Rikard
&gt; 
&gt; Serge Aleynikov wrote:
&gt; 
&gt;&gt; I need to be able to set the exit code at completion of the emulator 
&gt;&gt; process, so that I can distinguish from the OS whether the emulator 
&gt;&gt; finished with reasons other than 'normal' or 'shutdown'.  Is there a 
&gt;&gt; way to do that?
&gt;&gt;
&gt;&gt; erlang:halt(), init:stop(), etc. don't seem to have such an option.
&gt;&gt;
&gt;&gt; Thanks.
&gt;&gt;
&gt;&gt; Serge

]