# replacing system("date") with: defined(my $pid = fork) or die "Cannot fork: $!"; unless($pid) { # I'm the child # make your env changes here # you can also change directory, umask, priority, etc. exec "date"; die "date not found (just like me last friday night)"; } # parent continues here... { # to emulate system(), we need to ignore INT and QUIT # while the kid is foreground local $SIG{INT} = local $SIG{QUIT} = 'IGNORE'; waitpid($pid, 0); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: open-coding a system() operation
by Juerd (Abbot) on Apr 22, 2003 at 00:35 UTC | |
by merlyn (Sage) on Apr 22, 2003 at 02:40 UTC | |
by dug (Chaplain) on Apr 22, 2003 at 04:14 UTC | |
|
Re: open-coding a system() operation
by Anonymous Monk on Jan 02, 2004 at 19:10 UTC |