Try this...
close STDIN; close STDOUT; close STDERR;
if (open(DEVTTY, "/dev/tty")) {
ioctl(DEVTTY,0x20007471,0);
close DEVTTY;
}
open(STDIN,"</dev/null");
open(STDOUT,">/dev/null");
open(STDERR,">&STDOUT");
# at this point there are two processes... for parent, fork wi
+ll return a 'true' number,
# for child it'll return 0. thus, parent will exit and child w
+ill remain to run.
fork && exit;
# certain signals should be ignored
$SIG{"HUP"} = $SIG{"ALRM"} = $SIG{"PIPE"} = $SIG{"INT"} = "IGN
+ORE";
# set some priority for the process...
# (so that it doesn't end up wasting your
# server resources)
setpriority( "PRIO_PROCESS", 0, 10 );
|