develooper Front page | perl.par | Postings from May 2008

2 processes of par exe's

From:
bob davis
Date:
May 28, 2008 21:17
Subject:
2 processes of par exe's
Message ID:
483E2E3D.50207@bobsbits.net
par exe's have 2 processes.
One that extracts the files. (parent)
One that is the actual script running. (child)

Correct?

If I control-C the exe from the console window both processes go away.
(GOOD)
If I kill the child process the child and parent go away.
(GOOD)
If I kill the parent then the child becomes a zombie.
(BAD)

Is there anyway to guarantee the termination of the child process?
I have experimented with process::info and am able to find the zombie's 
and kill them. But I would like a little more immediate termination when 
the parent gets the axe.

Here is a sample program to experiment with:

pp -o sleeploop.exe -e "$SIG{INT}=sub{print qq(killed me), $@; exit(0) 
};while(1) {sleep 5; print qq(here), ++$i)"

executing sleeploop and ^C after about 13 seconds causes the here 1 here 
2 and killed me output.
This was just a test to see if I could trap signals and the program only 
traps sigint from the console. If a another program sends the signals 
they never get to sleeploop's signal trap. If I use this perl program I 
can kill it:
perl -e "print kill 1, <pid>"
Only 1, 3, and 9 can kill sleeploop.
Also I can kill it with:
1. pskill from sysinternals
2. Task manager
3. any other kill program

They all exhibit the zombie making features as explained above.

BTW the application I am using this for is a service that gets stopped 
from the windows service manager. I have tried to get 
Win32::Daemon::Simple to work but it requires Win32::Daemon and I cant 
find it. I really dont want to implement a service.
I have tried srvany from ms and I am currently using cygrunsrv from cygwin.

bob



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About