>>>>> "grocery" == grocery stocker <> writes:
grocery> Why can't we just trap the signal and have it exit? Ie like
grocery> sub sig {
grocery> exit;
grocery> }
grocery> $SIG{INT} = \&sig;
system is really just a convenience method for the following steps:
sub my_system {
my @args = @_;
defined (my $kidpid = fork) or die "Cannot fork: $!";
unless ($kidpid) { # kid does:
exec @args;
die "Cannot find $args[0]: $!";
}
# parent does:
{
local $SIG{INT} = $SIG{QUIT} = 'IGNORE';
waitpid($kidpid);
}
return $?;
}
If you want slightly different behavior, just copy this, and amend as
necessary. For example, just before the exec, you can do things like change
directory, close or open filehandles, set the process priority, and so on. In
your case, you can set up different signal handlers around the waitpid.
print "Just another Perl hacker,";
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
Posted via a free Usenet account from
http://www.teranews.com