aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-06-14 21:01:56 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-06-14 21:01:56 -0300
commitb11270a9e24cbae5d96847850b6aef9ce1e61451 (patch)
treea12b0f398eb7cc2c04d4fd73add4c5e8865c196d
parent5cfe6dec84e7a75de96523fb3abbe49cdedbc900 (diff)
downloadkvmx-b11270a9e24cbae5d96847850b6aef9ce1e61451.tar.gz
kvmx-b11270a9e24cbae5d96847850b6aef9ce1e61451.tar.bz2
Enhanced nohup strategy for kvmx-shell
-rwxr-xr-xkvmx18
1 files changed, 15 insertions, 3 deletions
diff --git a/kvmx b/kvmx
index 8de8d23..6386e7c 100755
--- a/kvmx
+++ b/kvmx
@@ -1772,6 +1772,7 @@ function kvmx_version {
# Shell
function kvmx_shell {
+ local tail=""
local restricted="$1"
local restricted_actions=":status:start:stop:poweroff:suspend:resume:console:monitor"
restricted_actions="$restricted_actions:wipe:shred:app_base:version:list_image:kill:"
@@ -1794,8 +1795,14 @@ function kvmx_shell {
else
if [ "${STDIN[0]}" == "up" ] || [ "${STDIN[0]}" == "start" ] || [ "${STDIN[0]}" == "restart" ]; then
# Process command, nohup version, stdout and stderr are redirected to a file
- nohup $APP_BASE/kvmx ${STDIN[0]} $VM ${STDIN[@]:1} >> $LOG_DIR/nohup 2>&1 &
- tail -F $LOG_DIR/nohup &
+ nohup $APP_BASE/kvmx ${STDIN[0]} $VM ${STDIN[@]:1} < /dev/null >> $LOG_DIR/nohup 2>&1 &
+
+ sleep 1
+ if [ -e "$LOG_DIR/nohup" ] && [ -z "$tail" ]; then
+ tail -F $LOG_DIR/nohup &
+ tail="$1"
+ fi
+ sleep 1
# Process command, disown version, stdout are preserved
#$APP_BASE/kvmx ${STDIN[0]} $VM ${STDIN[@]:1} &
@@ -1807,7 +1814,7 @@ function kvmx_shell {
else
if [ "${STDIN[0]}" == "up" ] || [ "${STDIN[0]}" == "start" ] || [ "${STDIN[0]}" == "restart" ]; then
# Process command, nohup version
- nohup $APP_BASE/kvmx ${STDIN[0]} $VM ${STDIN[@]:1} >> $LOG_DIR/nohup 2>&1 &
+ nohup $APP_BASE/kvmx ${STDIN[0]} $VM ${STDIN[@]:1} < /dev/null >> $LOG_DIR/nohup 2>&1 &
tail -F $LOG_DIR/nohup &
# Process command, disown version
@@ -1819,6 +1826,11 @@ function kvmx_shell {
fi
fi
done
+
+ if [ ! -z "$tail" ]; then
+ kill $tail &> /dev/null
+ rm -f $LOG_DIR/nohup
+ fi
}
# Xrandr integration