|
|
1 use POSIX qw(setsid);
2
3 chdir '/' or die "Can't chdir to /: $!";
4 umask 0;
5 open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
6 #open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
7 open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";
8 defined(my $pid = fork) or die "Can't fork: $!";
9 exit if $pid;
10 setsid or die "Can't start a new session: $!";
11
12 while(1) {
13 sleep(5);
14 print "Hello...\n";
15 }
|
|