Revision b61e8960
Added by Jim Pingle about 13 years ago
etc/inc/util.inc | ||
---|---|---|
953 | 953 |
} |
954 | 954 |
|
955 | 955 |
/* wrapper for exec() */ |
956 |
function mwexec($command, $mute = false) { |
|
956 |
function mwexec($command, $mute = false, $clearsigmask = false) {
|
|
957 | 957 |
global $g; |
958 | 958 |
|
959 | 959 |
if ($g['debug']) { |
... | ... | |
962 | 962 |
} |
963 | 963 |
$oarr = array(); |
964 | 964 |
$retval = 0; |
965 |
|
|
966 |
if ($clearsigmask) { |
|
967 |
$oldset = array(); |
|
968 |
pcntl_sigprocmask(SIG_SETMASK, array(), $oldset); |
|
969 |
} |
|
965 | 970 |
$garbage = exec("$command 2>&1", $oarr, $retval); |
971 |
if ($clearsigmask) { |
|
972 |
pcntl_sigprocmask(SIG_SETMASK, $oldset); |
|
973 |
} |
|
966 | 974 |
|
967 | 975 |
if(isset($config['system']['developerspew'])) |
968 | 976 |
$mute = false; |
... | ... | |
974 | 982 |
} |
975 | 983 |
|
976 | 984 |
/* wrapper for exec() in background */ |
977 |
function mwexec_bg($command) { |
|
985 |
function mwexec_bg($command, $clearsigmask = false) {
|
|
978 | 986 |
global $g; |
979 | 987 |
|
980 | 988 |
if ($g['debug']) { |
... | ... | |
982 | 990 |
echo "mwexec(): $command\n"; |
983 | 991 |
} |
984 | 992 |
|
993 |
if ($clearsigmask) { |
|
994 |
$oldset = array(); |
|
995 |
pcntl_sigprocmask(SIG_SETMASK, array(), $oldset); |
|
996 |
} |
|
985 | 997 |
exec("nohup $command > /dev/null 2>&1 &"); |
998 |
if ($clearsigmask) { |
|
999 |
pcntl_sigprocmask(SIG_SETMASK, $oldset); |
|
1000 |
} |
|
986 | 1001 |
} |
987 | 1002 |
|
988 | 1003 |
/* unlink a file, if it exists */ |
etc/rc.bootup | ||
---|---|---|
309 | 309 |
echo "Starting NTP time client..."; |
310 | 310 |
/* At bootup this will just write the config, ntpd will launch from ntpdate_sync_once.sh */ |
311 | 311 |
system_ntp_configure(false); |
312 |
mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh"); |
|
312 |
mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh", true);
|
|
313 | 313 |
|
314 | 314 |
/* start load balancer daemon */ |
315 | 315 |
relayd_configure(); |
etc/rc.newwanip | ||
---|---|---|
51 | 51 |
|
52 | 52 |
/* restart packages */ |
53 | 53 |
system_ntp_configure(false); |
54 |
mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh"); |
|
54 |
mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh", true);
|
|
55 | 55 |
log_error("{$g['product_name']} package system has detected an ip change $oldip -> $curwanip ... Restarting packages."); |
56 | 56 |
send_event("service reload packages"); |
57 | 57 |
} |
etc/rc.newwanipv6 | ||
---|---|---|
63 | 63 |
|
64 | 64 |
/* restart packages */ |
65 | 65 |
system_ntp_configure(false); |
66 |
mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh"); |
|
66 |
mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh", true);
|
|
67 | 67 |
log_error("{$g['product_name']} package system has detected an ip change $oldip -> $curwanip ... Restarting packages."); |
68 | 68 |
mwexec_bg("/etc/rc.start_packages"); |
69 | 69 |
} |
Also available in: Unified diff
Teach mwexec and mwexec_bg how to optionally clear signal masks, and use that when launching ntp or ntpdate.