how do I pass sound path as argument to fork()?You don't,
fork does not take any arguments.
fork creates an (almost) identical child process to the parent, there is no need to pass any arguments to the child, all the variable values that are in the parent are in the child. Are you perhaps missing
exec?
how do I kill this process, lets say, after 10 seconds automatically
See
alarm, so for example (untested):
my $g_pid = 0;
sub AlarmHandler {
kill 'KILL', $g_pid if $g_pid;
$g_pid = 0;
}
local %SIG;
$SIG{'ALRM'} = \&AlarmHandler;
alarm ($Seconds);
$g_pid = fork();
# blah, blah, blah
alarm(0); # Turn off the timer
The
kill will invode a SIGCHLD handler, if you have one.