If I have the code below to fork a child process, how would the right
way be to fork as a different user? I gather that fork() itself does
not support that, so some other method must be used.
Regards,
Lars
-----
#!/usr/bin/perl
use strict;
use warnings;
use English; # for $UID and such
my $old_uid = $UID;
$UID = 1000;
my $pid = fork();
unless( $pid ){
print qq(\tThis is a child process, PID $$\n);
print qq(\tThe child UID is $UID \n);
sleep 5;
exit 0;
}
$UID = $old_uid;
print qq(This is the parent process PID $PID and a child PID is $pid\n);
print qq(The parent is running as UID $UID \n);
sleep 5;
exit 0;
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/