AnyEvent::Socket issues wiht unix:/

Marc Lehmann schmorp at schmorp.de
Sun Nov 3 14:27:19 CET 2013


On Sat, Nov 02, 2013 at 01:50:17PM +0200, Gelu Lupas <ggl at devnull.ro> wrote:
> it or code references. I am having issues with the tcp_server when running
> it on an unix socket because the socket goes away when the listener gets
> destroyed in some particular circumstances when the child exists.

It always goes away when the listener is destroyed.

> example when the command to be executed is missing or when running a code
> reference and sening the child running the code ref a TERM signal.

TERM by default doesn't cause anything to be destroyed, it simply kills the
program.

Most likely you have a signal watcher for TERM and from there, cause the
listener to be destroyed by exiting wrongly.

This is common error for beginner unix programmers - without going into
details, the solution is to call POSIX::_exit to exit your subprocess,
or by not having a TERM signal watcher, or, best yet, by not using fork
for multiprocessing, because it is full of traps like this (and isn't
particularly portable in perl these days).

Using fork to exec another process (e.g. your program with a special
parameter that tells ti to be a child) is much better.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list