[erlang-questions] How do you kill an OS process that was opened with open_port on a brutal_kill?

Vans S vans_163@REDACTED
Fri Nov 25 21:44:42 CET 2016


> Yes, but that shouldn't be any actual cost beyond a comparitively small
> amount of memory (that can be mostly paged out even if you don't have
> swap) - it doesn't actually *do* anything, just sits in a blocking
> read(2) of its stdin.

The cost is indeed there, but in human cognitive resources :)

I need to manage these processes and know if something is running or not outside of erlang.  
A simple way I was doing this was by grepping /proc both for the process name and for
a uuid stored in its commandline. Maybe there is a better way?

With these 2 processes having duplicate command lines I need to write some extra logic.

Another key reason to grep /proc cmdline like this, is that I can guarantee a
process with a certain uuid is not started twice, say if an erlang process goes into an undefined state. 




On Friday, November 25, 2016 2:38 PM, Per Hedeland <per@REDACTED> wrote:
On 2016-11-25 18:17, Vans S wrote:
> Per Hedeland and José Valim that method works great.  One small peeve is it makes an extra process

Yes, but that shouldn't be any actual cost beyond a comparitively small
amount of memory (that can be mostly paged out even if you don't have
swap) - it doesn't actually *do* anything, just sits in a blocking
read(2) of its stdin.

> but the only way around this would be to patch the OS Processes code to terminate when stdin closes.

Assuming that you mean modifying the "target" program, yes - this would
be the "best" solution, but there are many cases where it is problematic
- obviously if you don't actually have the source code, but even if you
do, the modification can be non-trivial in a complex program, and it's a
pain to keep modifying the code and running the modified version when
new versions are released, etc.

> For now using the shell script is more then enough.

Great!


--Per



More information about the erlang-questions mailing list