[erlang-questions] closing a port doesn't kill the connected process?
Hynek Vychodil
hynek@REDACTED
Wed Mar 24 01:08:47 CET 2010
I'm using similar approach. First thing which port process does is
sending its PID. Then I set monitor or other linked process to port
owner which kills port process if doesn't behave right. Well behaving
process is ended by protocol message. If BEAM exits, process should
receive SIGPIPE. Default behavior is die on SIGPIPE and well behaving
process should not override it. All this together should catch most of
cases. It is mine best.
On Mon, Mar 22, 2010 at 8:17 PM, Paul Davis <paul.joseph.davis@REDACTED> wrote:
> On Mon, Mar 22, 2010 at 3:00 PM, Jacob Vorreuter
> <jacob.vorreuter@REDACTED> wrote:
>> I'm starting a redis server instance by opening an Erlang port. When the Erlang process exits or I explicitly close the port the os process is not killed. Is there a way to accomplish that?
>>
>> 1> Port = erlang:open_port({spawn, "redis-server"}, [binary, exit_status]).
>> #Port<0.429>
>> 2> erlang:port_close(Port).
>> true
>>
>> $ ps -ax | grep redis-server
>> 31374 ?? 0:00.02 redis-server
>>
>> Thanks,
>>
>> Jake
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>>
>>
>
> Jacob,
>
> We had to deal with that issue in CouchDB, although our solution isn't
> extremely elegant [1]. That spawnkillable code basically echos the os
> process id back to Erlang and then uses exec to replace itself with
> the requested command. Well behaved processes are expected to still
> close when they detect that their stdin has been closed.
>
> It all seems less than ideal, so I'd also be quite interested if
> someone knows of a better way to handle such things.
>
> Paul Davis
>
> [1] http://github.com/apache/couchdb/tree/trunk/src/couchdb/priv/spawnkillable/
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
--
--Hynek (Pichi) Vychodil
Analyze your data in minutes. Share your insights instantly. Thrill
your boss. Be a data hero!
Try GoodData now for free: www.gooddata.com
More information about the erlang-questions
mailing list