X-Git-Url: https://git.tld-linux.org/?p=rc-scripts.git;a=blobdiff_plain;f=lib%2Ffunctions;h=fb41ffa17f86c6ee922679bc64e1bf5dd04151cc;hp=fac4c46e67cfccdca16a3f8369cbc08f803ce7c8;hb=49ade4f4b5b1978db4561d62063008a339a1526f;hpb=2d25be2988d266692b556fbcc89c5b9108cf16f8 diff --git a/lib/functions b/lib/functions index fac4c46..fb41ffa 100644 --- a/lib/functions +++ b/lib/functions @@ -605,16 +605,90 @@ _daemon_set_ulimits() { done } +# inner function used by daemon(). +# do not call this directly, as it expects variables being inherited. +# also it expects to be called from subshell as it exports env. +# it expects options parsed by daemon() and command to be executed in "$@". +_daemon_exec() { + local prog="" + umask ${SERVICE_UMASK:-$DEFAULT_SERVICE_UMASK}; + export USER=root HOME=/tmp TMPDIR=/tmp + + nice=${nice:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} + nice=${nice:-0} + + # make nice level absolute, not to be dependant of nice level of shell where service started + nice=$(($nice - $(nice))) + + if [ "$closefds" = 1 ]; then + exec 1>&- + exec 2>&- + exec 0<&- + elif [ "$redirfds" = 1 ]; then + exec 1>/dev/null + exec 2>/dev/null + exec 0&1 + exec 0&1 "/dev/cpuset/${SERVICE_CPUSET}/tasks" - if errors=$( - umask ${SERVICE_UMASK:-$DEFAULT_SERVICE_UMASK}; - export USER=root HOME=/tmp TMPDIR=/tmp - - nice=${nice:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} - nice=${nice:-0} - - # make nice level absolute, not to be dependant of nice level of shell where service started - nice=$(($nice - $(nice))) - - if [ "$closefds" = 1 ]; then - exec 1>&- - exec 2>&- - exec 0<&- - elif [ "$redirfds" = 1 ]; then - exec 1>/dev/null - exec 2>/dev/null - exec 0&1 - exec 0&1