From 23a58e953de14f6033791aacfe8321f90bf8682a Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sat, 17 Jun 2017 14:07:57 +1000 Subject: [PATCH] Fix start/restart not closing stdout --- tools/arkmanager | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/arkmanager b/tools/arkmanager index f93e68c..5ef4537 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -1122,6 +1122,14 @@ doRun() { done } +doRunBG(){ + for fd in $(ls /proc/$BASHPID/fd/); do + [[ $fd -gt 2 && $fd != 255 ]] && exec {fd}<&- + done + + doRun "$@" > >(while read -r l; do printf "%s: [%s] %s\n" "$(timestamp)" "${instance}" "${l}"; done) 2>&1 +} + # # start function # @@ -1165,7 +1173,7 @@ doStart() { doRun "$@" return elif [[ -n "$arkPriorityBoost" || -n "$arkCpuAffinity" ]]; then - doRun --wait >(while read -r l; do printf "%s: [%s] %s\n" "$(timestamp)" "${instance}" "${l}" >>"$logdir/$arkserverLog"; done) 2>&1 & # output of this command is logged + doRunBG --wait >"$logdir/$arkserverLog" 2>&1 & # output of this command is logged local pid="$!" # Wait for monitor process to suspend itself @@ -1183,7 +1191,7 @@ doStart() { kill -CONT "$pid" else - doRun >(while read -r l; do printf "%s: [%s] %s\n" "$(timestamp)" "${instance}" "${l}" >>"$logdir/$arkserverLog"; done) 2>&1 & # output of this command is logged + doRunBG >"$logdir/$arkserverLog" 2>&1 & # output of this command is logged fi tput rc; tput ed; logprint "The server is now running, and should be up within 10 minutes"