Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $tmp = select(SEXTANT_DAEMON_LOG);
- $| = 1;
- select(SEXTANT_DAEMON_LOG);
- if ($daemon_mode) {
- log_message('daemon mode started, attempting to fork...', 1);
- defined($cpid1 = fork()) or die "pid$$[" . localtime(time()) . "] unable to fork: $!\n";
- if ($cpid1) {
- log_message('fork1 successful, child PID=' . $cpid1 . ', exiting...', 1);
- close(SEXTANT_DAEMON_LOG);
- $MAIN_DBH->disconnect();
- exit(0);
- }
- POSIX::setsid() or die "pid$$[" . localtime(time()) . "] unable to set session leader\n";
- defined($cpid2 = fork()) or die "pid$$[" . localtime(time()) . "] unable to fork: $!\n";
- if ($cpid2) {
- log_message('fork2 successful, child PID=' . $cpid2 . ', exiting...', 1);
- close(SEXTANT_DAEMON_LOG);
- $MAIN_DBH->disconnect();
- exit(0);
- }
- log_message('child (daemon) started', 1);
- chdir('/');
- umask(0);
- open(STDIN, '<', '/dev/null') or die "pid$$[" . localtime(time()) . "] unable to open stdin stream to /dev/null, exiting...";
- open(STDOUT, '>>', $fs_logfile) or die "pid$$[" . localtime(time()) . "] unable to open stdout stream to $fs_logfile, exiting...";
- open(STDERR, '>>', $fs_logfile) or die "pid$$[" . localtime(time()) . "] unable to open stderr stream to $fs_logfile, exiting...";
- }
- else {
- log_message('non-daemon mode started', 1);
- }
- getScriptName(\$script_name);
- $SEXTANT_DAEMON_LOCKFILE = checkLock($script_name);
- $MAIN_DBH = getConnection('Main');
- $FS_DBH = getConnection('Sextant');
- $HDS_DBH = getConnection('hds');
- $MS_DBH = undef;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement