Hi Perlers, I'm trying to check on the status of a process by sending a SIGZERO to it with kill(). This SHOULD (according to the docs I've been reading) return false if the process died. But mine is not. It always returns true.
if( kill 0 => $pid ) { print "the process is OK\n"; } else { print "Something happened to the process: $!\n"; } And for me, the above ALWAYS returns true. I'm wondering if this is something to do with Solaris, and not Perl. Maybe this signal doesn't behave the same way under Solaris? Ok, In the middle of writing this email I decided to write up a quick and dirty test: #!/usr/bin/perl use warnings; use strict; my $pid = shift; if( kill 0 => $pid ) { print "Everything's ok\n"; } else { print "$pid is not ok: $!\n"; } When I run this code against a made up PID (I grep for it first to be sure it's not really there), It works as expected, and: 17455 is not ok: No such process is returned! That's good! that's what I want. but when I throw it in my larger, longer Daemon script, it doesn't do it right. Just to give some more explaination, My script daemonizes itself: sub daemonize { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '/dev/null' or die "Can't write to /dev/null: $!"; defined( my $pid = fork ) or die "Can't fork the monitor: $!"; exit if $pid; setsid or die "Can't start a new session: $!"; open STDERR, '>&STDOUT' or die "Can't dup STDOUT: $!"; } then, It starts a bunch of children, capturing all of their process ID in a hash: sub start_servers { my $cmdName = shift; defined( my $pid = fork ) or die "Can't fork the server $cmdName: $!"; if( $pid == 0 ) { # Child chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '/dev/null' or die "Can't write to /dev/null: $!"; setsid or die "Can't start a new session: $!"; open STDERR, '>&STDOUT' or die "Can't dup STDOUT: $!"; exec( $cmdName ); } else { # Parent $children{$pid} = "$cmdName"; } } Then, the original goes into a loop, checking the children and (for debug purposes at the moment) just prints some status: do { foreach( keys %children ) { if( kill 0 => $_ ) { print " - $_: $children{$_} is still ok.\n"; } else { print " * $_: $children{$_} is not responding: $!\n"; } } sleep 5; } while( 1 ); But ... I always get back the TRUE response, "- 17455: ./dummy_script is still ok.". Did I miss something? --Errin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>