in reply to Re: Running a daemon process as another user
in thread Running a daemon process as another user
ok this is very strange:
--
My opinions may have changed,
but not the fact that I am right
use POSIX qw/setuid setsid/; BEGIN { setuid scalar getpwnam 'qf3' or die $!; # Fork. my $pidFile = '/some/path/pid'; my $pid = fork; if ($pid) # parent: save PID { open PIDFILE, ">$pidFile" or die "can't open $pidFile: $!\n"; print PIDFILE $pid; close PIDFILE; exit 0; } } print "USER: ". getpwuid($<) . "\n";
USER will be root, but when I do a ps -ef it does:
toadi 20510 1 14 04:56 pts/0 00:00:01 /usr/bin/perl /some/ +path/daemon
--
My opinions may have changed,
but not the fact that I am right
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Running a daemon process as another user
by Happy-the-monk (Canon) on Oct 27, 2004 at 09:06 UTC |
In Section
Seekers of Perl Wisdom