open_port
Matthias Lang
matthias@REDACTED
Thu Jan 12 09:41:09 CET 2006
If you add the "exit_status" option to the call to open_port, you get
exactly what you asked for:
1> erlang:open_port({spawn, "/tmp/a.out"}, [exit_status]).
#Port<0.79>
2> flush().
Shell got {#Port<0.79>,{exit_status,136}}
3> erlang:open_port({spawn, "/bin/true"}, [exit_status]).
#Port<0.83>
4> flush().
Shell got {#Port<0.83>,{exit_status,0}}
Matthias
--------------------
Dietmar Schaefer writes:
> Is there a way to distinguish the exit status of an unix process started
> by open_port ?
>
> No matter if my process terminates because of a devide by zero or I
> close it ->
> Reason is always normal
>
>
> handle_info({'EXIT', Port, Reason}, Port) ->
> io:format("External program exited Reason=~p Port=~p~n",
> [Reason, Port]),
> {stop, shutdown, noport};
More information about the erlang-questions
mailing list