|
@@ -18,6 +18,7 @@ LOG_DIR="$LOG_ROOT"/"$PROG"/"$SUBPROG"/"$TIMESTAMP"
|
|
|
|
|
|
mkdir -p "$LOG_DIR"
|
|
|
|
|
|
+PTY="$LOG_DIR"/pty
|
|
|
OUT="$LOG_DIR"/stdout
|
|
|
ERR="$LOG_DIR"/stderr
|
|
|
DAT="$LOG_DIR"/dat
|
|
@@ -29,14 +30,16 @@ info(){
|
|
|
$CMD
|
|
|
status=$?
|
|
|
EOF
|
|
|
- exec 2>&-
|
|
|
- exec 1>&-
|
|
|
- wait "$err_pid" "$out_pid"
|
|
|
+ exec 1>&- 2>&-
|
|
|
+ kill "$socat_out"
|
|
|
+ wait
|
|
|
}
|
|
|
|
|
|
trap 'info' EXIT
|
|
|
+tty="$(tty)"
|
|
|
+socat PTY,rawer,link="$PTY" EXEC:"tee -a \"$DAT\" \"$OUT\" \"$tty\"" &
|
|
|
+socat_out="$!"
|
|
|
+while ! [ -e "$PTY" ]; do sleep 0.1; done
|
|
|
exec 2> >(tee -a "$DAT" "$ERR")
|
|
|
-err_pid="$!"
|
|
|
-exec 1> >(tee -a "$DAT" "$OUT")
|
|
|
-out_pid="$!"
|
|
|
+exec 1> "$PTY"
|
|
|
"$@"
|