diff options
author | Andrew Cady <d@jerkface.net> | 2024-08-20 21:45:14 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2024-08-20 21:45:14 -0400 |
commit | cd1a4ac7692ec73a35cfdb86334a5e9655d9a609 (patch) | |
tree | 8a604b30cacb431c7e0b4b12311c5d606ebc0bef /src/twopane.bash | |
parent | 62440f41b97fbe85787bb015c9f52bf7e329b97c (diff) |
fix all problems with signals?
Diffstat (limited to 'src/twopane.bash')
-rwxr-xr-x | src/twopane.bash | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/twopane.bash b/src/twopane.bash index 4c3ec62..7056053 100755 --- a/src/twopane.bash +++ b/src/twopane.bash | |||
@@ -89,14 +89,15 @@ kill_screen_pane() | |||
89 | 89 | ||
90 | start_screen_pane() | 90 | start_screen_pane() |
91 | { | 91 | { |
92 | declare -g -a PANES | 92 | # declare -g -a PANES |
93 | declare -i pane="${1:-1}" | 93 | declare -i pane="${1:-1}" |
94 | (( pane > 0 )) || return | 94 | (( pane > 0 )) || return |
95 | PANES+=("$pane") | 95 | # PANES+=("$pane") |
96 | if check_screen_pane "$pane" | 96 | if check_screen_pane "$pane" |
97 | then | 97 | then |
98 | return | 98 | return |
99 | fi | 99 | fi |
100 | shift | ||
100 | if [ $# = 0 ] | 101 | if [ $# = 0 ] |
101 | then | 102 | then |
102 | set -f | 103 | set -f |
@@ -105,7 +106,7 @@ start_screen_pane() | |||
105 | TOP_TITLE="Command: ${*@Q}" | 106 | TOP_TITLE="Command: ${*@Q}" |
106 | screen -X focus top | 107 | screen -X focus top |
107 | screen -X screen -ln -t "$TOP_TITLE" 1 "$@" | 108 | screen -X screen -ln -t "$TOP_TITLE" 1 "$@" |
108 | screen -p "$pane" -X exec .!. bash -c 'exec -a top-tty-forward socat UNIX-LISTEN:"$TWOPANE"/socket STDIN,cfmakeraw!!STDOUT' | 109 | screen -p "$pane" -X exec .!. bash -c 'exec -a top-pane-tty-forward socat UNIX-LISTEN:"$TWOPANE"/socket STDIN,cfmakeraw!!STDOUT' |
109 | } | 110 | } |
110 | 111 | ||
111 | restart_screen_pane() | 112 | restart_screen_pane() |
@@ -219,15 +220,25 @@ pid_to_jobspec() | |||
219 | 220 | ||
220 | tty_forward() | 221 | tty_forward() |
221 | { | 222 | { |
222 | declare -i -n pid="$1" | 223 | declare -i pid="$1" |
223 | read-tty | 224 | read-tty |
224 | x kill $pid 2>/dev/null | 225 | x kill $pid |
225 | } | 226 | } |
226 | 227 | ||
227 | SOCAT() | 228 | SOCAT() |
228 | { | 229 | { |
229 | (exec -a bottom-tty-forward socat - UNIX-CONNECT:"$TWOPANE"/socket,forever) | 230 | (exec -a bottom-pane-tty-forward socat - UNIX-CONNECT:"$TWOPANE"/socket,forever) |
230 | x kill -USR1 $$ | 231 | case "$TOP_EXIT" in |
232 | restart ) | ||
233 | start_screen_pane 1 "$@" | ||
234 | ;; | ||
235 | quit ) | ||
236 | quit | ||
237 | ;; | ||
238 | prompt | * ) | ||
239 | ;; | ||
240 | esac | ||
241 | x screen -X quit | ||
231 | } | 242 | } |
232 | 243 | ||
233 | echosend() | 244 | echosend() |
@@ -256,11 +267,11 @@ quiet_bg() | |||
256 | 267 | ||
257 | background() | 268 | background() |
258 | { | 269 | { |
259 | start_screen_pane "$@" | 270 | start_screen_pane 1 "$@" |
260 | focus bottom | 271 | focus bottom |
261 | echosend ECHOSEND | 272 | echosend ECHOSEND |
262 | { | 273 | { |
263 | tty_forward ECHOSEND_PID & | 274 | eval "tty_forward $ECHOSEND_PID &" |
264 | } >&$ECHOSEND | 275 | } >&$ECHOSEND |
265 | TTY_READER_PID=$! | 276 | TTY_READER_PID=$! |
266 | printf '%s\n' \ | 277 | printf '%s\n' \ |
@@ -370,7 +381,7 @@ tokenize() | |||
370 | # If it is a non-printable, then we output a | 381 | # If it is a non-printable, then we output a |
371 | # multi-character line. In this case we colorize it | 382 | # multi-character line. In this case we colorize it |
372 | # later so that it won't be confused with multiple | 383 | # later so that it won't be confused with multiple |
373 | # printable characters. | 384 | # printable characters in the . |
374 | printf '\\%.3o\n' "'$REPLY" | 385 | printf '\\%.3o\n' "'$REPLY" |
375 | continue | 386 | continue |
376 | fi | 387 | fi |
@@ -401,6 +412,7 @@ our_bashrc_main() | |||
401 | set -o pipefail | 412 | set -o pipefail |
402 | #trap 'focus bottom; resize 90%; read -p "Exit> "; quit' EXIT | 413 | #trap 'focus bottom; resize 90%; read -p "Exit> "; quit' EXIT |
403 | #trap 'echo USR1 >&2; focus bottom; x kill -INT %tty_forward $TTY_READER_PID $ECHOSEND_PID' USR1 | 414 | #trap 'echo USR1 >&2; focus bottom; x kill -INT %tty_forward $TTY_READER_PID $ECHOSEND_PID' USR1 |
415 | trap 'quit' USR1 | ||
404 | export PS1="$BOT_TITLE\\\$ " | 416 | export PS1="$BOT_TITLE\\\$ " |
405 | } | 417 | } |
406 | 418 | ||