[erlang-questions 82] Re: code:lib_dir and .ez archives

Håkan Mattsson <>
Mon Mar 28 14:29:47 CEST 2011


On Mon, Mar 28, 2011 at 8:52 AM, Max Lapshin <> wrote:
> There is other problem with escript: it cannot go background.
> It would be very convenient for me to distribute erlyvideo in small
> single-file launch scripts, but I can't do it because it doesn't allow
> to go background.

Yes, you can (forcefully) put it in background with the -detached option:

    %%! -detached

It is ugly, but it works.

Per Hedeland has however implemented a much better solution called delayed
detach, where the detached Erlang node keeps a socket to its parent process so
it may print a decent error message and set an exit code if the
startup fails. It is up
to the application to decide whether the detach should completed or if
it is an error
case. The code has been contributed to the OTP group a long time ago, but was
at that timepoint not included in the distribution due to lack of
time. The code has
proven to work very well.

Delayed detach would be a perfect fit for usage with escripts.

/Håkan



More information about the erlang-questions mailing list