[EMAIL PROTECTED] wrote: > Hi there > > I'm stuck with system(). According to some posts, system() is passing > SIGINT and SIGQUIT to it's child, yet this doesn't seem to work.
No, I don't think that's correct. A terminal driver will catch ^C and ^\ and send the appropriate signals to all the processes in the foreground process group, but that has nothing to do with system(). > I've > boiled the code down to the following lines. (Please note that > 'alsaplayer' is a console soundfile player that honors SIGINT and > SIGQUIT by immediately quitting.) > > sub controler > { > my $pid = fork; > if (!$pid) { &player(); } (Lose the & char) Note that after player returns, the child will execute the code below. The child should exit() when it's finished. > while (!-e "stop") { sleep(10); } > kill('QUIT', $pid); Why use SIGQUIT? Do you want the core dump? SIGTERM would be the typical use. Also, $pid is the PID of your child, not the PID of alsaplayer. You kill a process group to send the signal to both, but if you exec() alsaplayer (see below), you don't have to fool with that. perldoc -f kill perldoc -f getpgrp > } > > sub player > { > system("alsaplayer -q song.mp3"); > sleep; Why should the child wait here? If it finishes, why not exit? Also, why not just use exec() instead of system()? That would make: sub player { exec 'alsaplayer -q song.mp3' } > } > > The controler forks off the player child which > system()-implicitly forks > again and runs alsaplayer in the child. So the sound's playing. I > 'touch stop' and the controler signals SIGQUIT to the player child. > This works as I can see when I catch SIGQUIT there. Still, the > SIGQUIT is not forwarded to the child running alsaplayer the way it > is supposed to do > - at least according > to my literature. I don't think that literature is correct. > > Am I missing something here? Any idea how I could do this differently? sub controller { defined(my $pid = fork) or die "Couldn't fork: $!"; exec('alsaplayer -q song.mp3') unless $pid; sleep 1 while !-e 'stop'; kill 'TERM', $pid; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]