diff options
-rwxr-xr-x | src/twopane.bash | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/twopane.bash b/src/twopane.bash index a715a7d..a349063 100755 --- a/src/twopane.bash +++ b/src/twopane.bash | |||
@@ -135,17 +135,22 @@ connect() | |||
135 | return 1 | 135 | return 1 |
136 | ;; | 136 | ;; |
137 | esac | 137 | esac |
138 | if ! [ "${SOCAT[0]}" ] | 138 | [ "${SOCAT[0]}" ] || socat_coproc |
139 | then | ||
140 | local STDERR | ||
141 | exec {STDERR}>&2 | ||
142 | { | ||
143 | coproc SOCAT { socat_connect; } 2>&$STDERR | ||
144 | } 2>/dev/null | ||
145 | eval "exec $STDERR>&-" | ||
146 | fi | ||
147 | pid=${SOCAT_PID} | 139 | pid=${SOCAT_PID} |
148 | exec {std0}<&${SOCAT[0]} {std1}>&${SOCAT[1]} | 140 | exec {std0}<&${SOCAT[0]} {std1}>&${SOCAT[1]} |
141 | } | ||
142 | |||
143 | socat_coproc() | ||
144 | { | ||
145 | set -m | ||
146 | local STDERR | ||
147 | exec {STDERR}>&2 | ||
148 | { | ||
149 | coproc SOCAT { | ||
150 | socat - UNIX-CONNECT:"$TWOPANE"/socket,forever | ||
151 | kill -USR1 $$ | ||
152 | } 2>&$STDERR {STDERR}>&- | ||
153 | } 2>/dev/null | ||
149 | disown | 154 | disown |
150 | } | 155 | } |
151 | 156 | ||