Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
It launches an xterm and after a time I'd like the xtermuse POSIX; my $pgrp; FORKTAIL:{ if($pidxt=fork){ #parent stuff print "First: ID is $pidxt\n"; print "Process ID of this script is: $$\n"; $pgrp = getpgrp $pidxt; }elsif (defined $pidxt){ #child stuff #$pgrp = getpgrp $pidxt; print "group id is: $pgrp\n"; print "Second: ID is: $pidxt\n"; #`xterm -sb -ls -vb -e tail -f $0`; `xterm -sb -ls -vb `; POSIX::exit(0); undef $pidxt; }else { die "Can't fork!\n"} } eval{ local $SIG{ALRM} = sub { print "id in kill is: $pidxt\n"; print "grp id is: $pgrp\n"; kill &POSIX::SIGTERM, $pgrp; waitpid($pidxt,0); die "alarm\n" }; alarm 15; waitpid($pidxt,0); alarm 0; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to kill an external program
by Fastolfe (Vicar) on Sep 07, 2000 at 21:23 UTC | |
|
Re: How to kill an external program
by kilinrax (Deacon) on Sep 07, 2000 at 21:21 UTC |