diff --git a/ssm b/ssm index 4b3dbab..33f4744 100755 --- a/ssm +++ b/ssm @@ -165,11 +165,6 @@ svc() { job_exit = 0 # Exit successfully by default 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. if cgroups; then if service_cgroup_cleanup; then @@ -197,7 +192,13 @@ svc() { # Die 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" @@ -268,9 +269,6 @@ svc() { wait "$job_pid"; job_exit=$? fi - # Record the job exit code - printf '%d' "$job_exit" > "$service_exit_file" - # One service failure, two service failures... if service_success_exit u "$job_exit"; then job_success = 1 @@ -452,7 +450,7 @@ start() { svc "${service_command[@]}" & job=$! if service_oneshot; then - wait "$job"; res=$? + wait -n "$job"; res=$? (( res )) && { printf '%s' "$res" > "$service_exit_file"