Put this content in "mainprogram" and 'chmod a+x'
#!/usr/bin/perl -w use strict; use warnings; use IPC::Open3; use IO::Select; my($StartedProcess); $SIG{USR1} = \&status; sub status () { $SIG{USR1} = \&status; print STDERR "Currently running: $StartedProcess\n"; } # Opens external program, and as long as it exists, checks # if there is data in the pipe (STDOUT/STDERR) sub createProcess () { my($line, $selector, @ready, $fh); $StartedProcess = open3(*CMD_IN, *CMD_OUT, *CMD_ERR, "./external.pp" +); close(CMD_IN); $selector = IO::Select->new(); $selector->add(*CMD_ERR, *CMD_OUT); while(@ready = $selector->can_read) { # do some operations on STDOUT/STDERR here } close(CMD_OUT); close(CMD_ERR); } my($pid) = fork; if($pid) { print "\t Created PID: $pid. run 'kill -s USR1 $pid'\n"; exit(0); } foreach(qw/1 2 3 4 5 6 7 8 9 10/) { createProcess(); } print STDERR "\n COMPLETED !"; exit(0);
#!/usr/bin/perl -w use strict; my $i = 0; while ($i <= 10) { sleep(3); $i+= 3; }
In reply to Re^7: Signal to parent-process. Does it affect it's children?
by rapide
in thread Signal to parent-process. Does it affect it's children?
by rapide
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |