[erlang-questions] Fwd: Report errors when using "-detached" option
Hynek Vychodil
vychodil.hynek@REDACTED
Thu Nov 20 15:11:52 CET 2008
No, it isn't.
$ erl -eval 'halt(77).'
Erlang (BEAM) emulator version 5.6.3 [source] [smp:2] [async-threads:0]
[hipe] [kernel-poll:false]
$ echo $?
77
$ erl -detached -eval 'halt(77).'
$ echo $?
0
On Tue, Nov 18, 2008 at 8:47 PM, Claes Wikstrom <klacke@REDACTED> wrote:
> ERLANG wrote:
> > Hi Nicolas,
> >
> >>>> This is indeed a real problem. If daemon startup fails, you
> >>>> typically
> >>>> want to indicate that through a call to exit(error_code) so that the
> >>>> invoker can check $?
> >>>>
> >>> Hmmm. Calling "exit(error_code)" isn't reported to the invoker.
> >>> So $? always equals to 0.
> >>>
> >>> Is this an expected behaviour of calling "exit(error_code)" when
> >>> using
> >>> "-detached" flag.
> >>>
> >> halt(error_code) works.
> >
> > No, It doesn't.
> >
>
> Yes it does,
>
> [klacke@REDACTED]~ > erl
> Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0]
> [kernel-poll:false]
>
> Eshell V5.6.5 (abort with ^G)
> 1> halt(77).
> [klacke@REDACTED]~ > echo $?
> 77
>
>
> But that's not the point. What's needed is to fork(), let the new code run
> for a while and check config/whatever, if all is well it calls foo:bar(ok)
> and the
> invoker eventually gets a status code 0, whereas if the forked process
> (beam)
> calls foo:bar({error, Code}) the invoker of erl -detached2 ... gets Code
> in the UNIX shell
>
>
> /klacke
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
--
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081120/24c4d41e/attachment.htm>
More information about the erlang-questions
mailing list