> -----Original Message-----
> From: Andre [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 10, 2002 9:55 PM
> To: [EMAIL PROTECTED]
> Subject: FORK USE ?
>
>
> Hi i want to execute an linux command as atotally separeted
> from the =
> father process
> Is it wrong?
> my script.....
> fork ("perl anotherscript.pl");
> .....
> my script go on...
No, fork doesn't work that way. fork() simply makes a second process which
is a duplicate of the first. In order to run a different program, you need
to call exec() after the fork:
defined(my $pid = fork) or die "Couldn't fork: $!";
unless ($pid) {
exec "perl anotherscript.pl" or die "Couldn't exec: $!";
}
... first process continues here ...
See:
perldoc -f fork
perldoc -f exec
perldoc -f wait
perldoc perlipc
You may want to take additional measures to disassociate the second process
from the controlling terminal and process group. See:
perldoc -q daemon
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]