[erlang-questions] Sending signals to non-erlang processes

Jesper Louis Andersen <>
Fri Oct 16 13:18:40 CEST 2015

On Fri, Oct 16, 2015 at 11:30 AM, Nicolas Martyanoff <>

> I also cannot find a way to actually stop the spawned application,
> port_close() does do it. The "UNIX way" is to send SIGTERM, wait for a bit,
> then send SIGKILL if the application did not stop. But I cannot find an
> erlang
> function to send a signal to an external process. I made a temporary fix
> using
> os:cmd("kill ..."), but it feels like a hack.

Two options: misbehaving programs can be handled through Aleynikov's
https://github.com/saleyn/erlexec which wraps[0] them in a C++ helper
process which understands how to gracefully communicate to the Erlang world.

Port programs normally communicate through a set of file descriptors, so
the program you spawn should detect and terminate if there are errors when
reading on the fd. I've been down this rabbit hole before, but I'm afraid I
forgot, again, how it all works. Perhaps this is good to document in a "How
to write behaving port programs" document and make it part of the OTP

[0] First time around I wrote "warps" here. Wrong, but strangely
appropriate :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151016/5d086995/attachment.html>

More information about the erlang-questions mailing list