> Yes, I have the Perl Cookbook. I think I've read and tried all the > relevant recipes from there, but I'm still unable to kill > grandchildren > when the child's output is redirected to /dev/null and the > parent is run > from a shell script. > > Here's the basic code simplified a bit for illustration--I > don't think it will help too much: > > my $pid; > unless ($pid = fork()) { > /mp3$/i and exec($mp3_player . " \"$_\"" . ($verbose ? "" > : " > /dev/null 2>&1")); > } > my $kid; > ReadMode 3; > do { > my $key = ReadKey(0.01) || ""; > $kid = waitpid(-1,WNOHANG) || 0; > if ($key eq "") { > } elsif ($key_next =~ /\Q$key\E/) { > print "Skipping to next song...\n" unless $quiet; > local $SIG{HUP} = 'IGNORE'; # don't want to > kill ourselves here! > kill HUP => -$$; # killing a > negative pid kills whole process group; shell and player > } elsif ($key_quit =~ /\Q$key\E/) { > print "Quitting...\n" unless $quiet; > local $SIG{HUP} = 'IGNORE'; > kill HUP => -$$; > last; > } > } until ($kid > 0); > > The problem here is the kill HUP => -$$ only works when the > parent is run > from the command prompt, not when run from another shell script. > --
your right the code is standard, I usually don't run perl scripts from shell scripts except for cron jobs. I will take a look at some of my similar scripts and see if I can find any kind of clue. Good Luck Jim --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.737 / Virus Database: 491 - Release Date: 8/11/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>