Leser: 22
1 2 3 4 5 6 7 8 9 10 11
$pid_c=fork(); #create child as working slave if ($pid_c==0){system("growisofs -Z $device=$isofile >$tmpfile 2>&1");exit;}; #child process does the job if ($pid_c!=0) #parent job only does output { for(;;) { select(undef,undef,undef,0.1); #sleep for 0.1 sec # Fortschritt abprüfen... if (kill(0,$pid_c)==0){last;} #child finished; go on } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
$pid_c=fork(); #create child as working slave if (defined $pid_c) { if ($pid_c==0) #child process does the job { system("growisofs -Z $device=$isofile >$tmpfile 2>&1"); exit; } else #parent job only does output { for(;;) { select(undef,undef,undef,0.1); #sleep for 0.1 sec # Fortschritt abprüfen... if (kill(0,$pid_c)==0) { last; #child finished; go on } } } } else { die ("Cant fork!"); }
2011-03-31T08:53:58 cyborg0001EDIT: auch $?=-1 sagt nur "No child processes"
if ($?==-1){print "Failure: $!\n";exit;}
1 2 3
system("growisofs -Z $device=$isofile >$tmpfile 2>&1"); if ($?==-1){print "Failure: $!\n";} exit;
2011-03-31T08:30:39 cyborg0001[...]
Code (perl): (dl )1 2 3 4 5 6for(;;) { select(undef,undef,undef,0.1); #sleep for 0.1 sec # Fortschritt abprüfen... if (kill(0,$pid_c)==0){last;} #child finished; go on }
[...]
waitpid($pid_c, 0); # wait until $pid_c terminates
1 2 3
use POSIX qw/:sys_wait_h/; ... waitpid($pid_c, WNOHANG); # poll whether process has terminated