[erlang-questions] How to kill a process started with open_port({spawn_executable, ... ?

Robert Raschke rtrlists@REDACTED
Thu Aug 25 18:30:29 CEST 2011


On Thu, Aug 25, 2011 at 4:51 PM, Paul Davis <paul.joseph.davis@REDACTED>wrote:

> I'm not sure if this is the cleanest approach or not, but in CouchDB
> we place a shim between Erlang and the OS process that reports a cmd
> that can be passed to os:cmd to execute the process. There's a version
> for both Unix and Windows.
>
> The Unix version in its entirety (minus the license):
>
>    #! /bin/sh -e
>    echo "kill -9 $$"
>    exec $*
>
> https://github.com/apache/couchdb/tree/trunk/src/couchdb/priv/spawnkillable
>
> On Thu, Aug 25, 2011 at 10:43 AM, Robert Raschke
> <rtrlists@REDACTED> wrote:
> > Hi,
> >
> > is it possible to explicitly kill an OS process that's been started with
> and
> > open_port({spawn_executable, "executable"}, ...) call from within Erlang?
> >
> > This is on Windows for me just now, in case there is a way and it differs
> > between OSes.
> >
> > Thanks,
> > Robby
>

Yeah, I was staring down that alleyway and thought, there must be something
better. 'Twould be nice if we had a port_close/2, that could take an option
to choose between killing or detaching from the OS process. But I guess
that's tricky, 'cause ports are so versatile.

Thanks for the link to the CouchDB approach, I might head down that route
after all.

Robby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110825/26574004/attachment.htm>


More information about the erlang-questions mailing list