[erlang-questions] open_port + spawn and closing the spawned application when port closes

Fred Hebert mononcqc@REDACTED
Wed Dec 19 14:11:11 CET 2018


On 12/13, Vans S wrote:
>I recall there was a way to do this by basho but wondering if there are new alternatives recently.
>
>Basically the example is a simple one, open_port({spawn, "curl -L "http://releases.ubuntu.com/18.04.1.0/ubuntu-18.04.1.0-live-server-amd64.iso?" --progress-bar -o /dev/null"}) now kill the process, close the port, or kill the emulator.  The curl process keeps running.  I believe it was when the port closes, stdin/stdout closes for the process, and the work around was to wrap the process in a bash script that would detect stdin/out closed, and terminate the process it wrapped.
>
>Any thoughts on this, or perhaps help finding that bash script again?

The safest option for a flexible case is https://github.com/saleyn/erlexec

You might have also thought of just using something like `cat | 
<command>' which would try to stop and shut things down when stdin 
closes, but erlexec is a safer bet.



More information about the erlang-questions mailing list