Hi..

To get myself in the rigt mood to continue working on my website, I 
daemonized Wayne Schlitt's ntp_clients today. It's nothing real fancy as 
I'm not a Perl wizard but it should do its job..

The patch is attached, there are two new options: pidfile defines the 
file where the PID is stored (surprise!) and logfile is where the former 
stdout goes.

Regards,
Niels
4a5
> # daemonized by Niels Ganser
17d17
< 
23a24,25
> my $LOGFILE = "";
> my $PIDFILE = "";
28a31,32
>                       'logfile=s'     => \$LOGFILE,
>                       'pidfile=s'     => \$PIDFILE,
41a46,47
>   print "      -logfile=/path/logfile    File to write former STDOUT\n";
>   print "      -pidfile=/path/pidfile    File to store PID\n";
53a60,74
> use POSIX qw (setsid);
> sub daemonize {
>   open STDIN, '/dev/null';
>   open STDOUT, ">$LOGFILE";
>   my $pid = fork;
>   exit if $pid;
>   setsid;
>   open STDERR, '>&STDOUT';
> }
> 
> daemonize();
> open(PIDF, ">$PIDFILE");
> print PIDF "$$\n";
> close(PIDF);
> 
_______________________________________________
timekeepers mailing list
[email protected]
https://fortytwo.ch/mailman/cgi-bin/listinfo/timekeepers

Reply via email to