More reliable handling; however, we still get 143 in the exit file if the job was interrupted
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
@@ -165,11 +165,6 @@ svc() {
|
|||||||
job_exit = 0 # Exit successfully by default
|
job_exit = 0 # Exit successfully by default
|
||||||
|
|
||||||
svc::cleanup() {
|
svc::cleanup() {
|
||||||
#nullexec kill -n "$service_stop_signal" "$job_pid"
|
|
||||||
nullexec "${service_stop_command[@]}"
|
|
||||||
|
|
||||||
anywait "$job_pid" "$service_stop_timeout"
|
|
||||||
|
|
||||||
# Cgroup stuff, experimental and pretty much deprecated.
|
# Cgroup stuff, experimental and pretty much deprecated.
|
||||||
if cgroups; then
|
if cgroups; then
|
||||||
if service_cgroup_cleanup; then
|
if service_cgroup_cleanup; then
|
||||||
@@ -197,7 +192,13 @@ svc() {
|
|||||||
|
|
||||||
# Die
|
# Die
|
||||||
die "$job_exit"
|
die "$job_exit"
|
||||||
}; trap 'svc::cleanup' TERM EXIT
|
}; trap 'svc::cleanup' EXIT
|
||||||
|
|
||||||
|
svc::stop_job() {
|
||||||
|
nullexec "${service_stop_command[@]}"
|
||||||
|
|
||||||
|
anywait "$job_pid" "$service_stop_timeout"
|
||||||
|
}; trap 'svc::stop_job' TERM
|
||||||
|
|
||||||
printf '%s' "$BASHPID" > "$svc_pidfile"
|
printf '%s' "$BASHPID" > "$svc_pidfile"
|
||||||
|
|
||||||
@@ -268,9 +269,6 @@ svc() {
|
|||||||
wait "$job_pid"; job_exit=$?
|
wait "$job_pid"; job_exit=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Record the job exit code
|
|
||||||
printf '%d' "$job_exit" > "$service_exit_file"
|
|
||||||
|
|
||||||
# One service failure, two service failures...
|
# One service failure, two service failures...
|
||||||
if service_success_exit u "$job_exit"; then
|
if service_success_exit u "$job_exit"; then
|
||||||
job_success = 1
|
job_success = 1
|
||||||
@@ -452,7 +450,7 @@ start() {
|
|||||||
svc "${service_command[@]}" & job=$!
|
svc "${service_command[@]}" & job=$!
|
||||||
|
|
||||||
if service_oneshot; then
|
if service_oneshot; then
|
||||||
wait "$job"; res=$?
|
wait -n "$job"; res=$?
|
||||||
|
|
||||||
(( res )) && {
|
(( res )) && {
|
||||||
printf '%s' "$res" > "$service_exit_file"
|
printf '%s' "$res" > "$service_exit_file"
|
||||||
|
|||||||
Reference in New Issue
Block a user