diff options
author | jim-p <jimp@pfsense.org> | 2012-05-16 14:03:24 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2012-05-16 14:03:24 -0400 |
commit | b61e89600ea0053d8ab4a9d0e18809cc29828b92 (patch) | |
tree | a1e9d4bc4a26cdb1dafd8efe8a82475af7ad0be2 /etc/inc | |
parent | 9cf11774f2921b6ac7794b8e132eeb10bf2e7286 (diff) | |
download | pfsense-b61e89600ea0053d8ab4a9d0e18809cc29828b92.zip pfsense-b61e89600ea0053d8ab4a9d0e18809cc29828b92.tar.gz |
Teach mwexec and mwexec_bg how to optionally clear signal masks, and use that when launching ntp or ntpdate.
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/util.inc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index a052fbc..d53b885 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -953,7 +953,7 @@ function exec_command($command) { } /* wrapper for exec() */ -function mwexec($command, $mute = false) { +function mwexec($command, $mute = false, $clearsigmask = false) { global $g; if ($g['debug']) { @@ -962,7 +962,15 @@ function mwexec($command, $mute = false) { } $oarr = array(); $retval = 0; + + if ($clearsigmask) { + $oldset = array(); + pcntl_sigprocmask(SIG_SETMASK, array(), $oldset); + } $garbage = exec("$command 2>&1", $oarr, $retval); + if ($clearsigmask) { + pcntl_sigprocmask(SIG_SETMASK, $oldset); + } if(isset($config['system']['developerspew'])) $mute = false; @@ -974,7 +982,7 @@ function mwexec($command, $mute = false) { } /* wrapper for exec() in background */ -function mwexec_bg($command) { +function mwexec_bg($command, $clearsigmask = false) { global $g; if ($g['debug']) { @@ -982,7 +990,14 @@ function mwexec_bg($command) { echo "mwexec(): $command\n"; } + if ($clearsigmask) { + $oldset = array(); + pcntl_sigprocmask(SIG_SETMASK, array(), $oldset); + } exec("nohup $command > /dev/null 2>&1 &"); + if ($clearsigmask) { + pcntl_sigprocmask(SIG_SETMASK, $oldset); + } } /* unlink a file, if it exists */ |