http://www.perlmonks.org?node_id=26722


in reply to Re: I got zombies
in thread I got zombies

There is no foreground process. It's using setsid() to disassociate the child from the parent, then the parent exits. The remaining process (the child) forks a process it's the parent of and they both do their own thing.

I should have just left out the setsid() because you're apparently confused by what I intended to do with it. I wasn't sure if it was pretinent or not, so I mentioned it.

I'm doing something like this:

use POSIX qw/setsid/; if ( fork() ) { exit; } else { setsid(); } # now the foreground process is gone and I'm the child if ( fork() ) { &do_something(); } else { &do_something_else(); }

They both stay around in an infinite loop doing whatever they're supposed to do. I have to kill them both or whichever one I don't kill sticks around. Like from ps auxf:

iniquity 26464 0.5 15.9 2976 2348 ? S 21:41 0:00 perl -w ./si +ncd.pl iniquity 26465 0.0 15.4 2920 2276 ? S 21:41 0:00 \_ perl -w +./sincd.p

If I kill 26464, 26465 doesn't go away.

local $_ = "0A72656B636148206C72655020726568746F6E41207473754A"; while(s/..$//) { print chr(hex($&)) }