UPD: bind-input/output now synchronous for the setup, then asynchronous (so the buffer file will always be ok)
This commit is contained in:
parent
534b5a97ac
commit
73e388aff8
26
bind-input
26
bind-input
|
@ -35,6 +35,16 @@ BUFFER="/tmp/inbuf_$IN_ID";
|
||||||
echo -n "" > $BUFFER;
|
echo -n "" > $BUFFER;
|
||||||
|
|
||||||
|
|
||||||
|
# (3) Remove buffer + kill loop #
|
||||||
|
on_exit(){
|
||||||
|
[[ $DEBUG ]] && echo " < closing binding port $IN_PT to $BUFFER";
|
||||||
|
rm $BUFFER 2>/dev/null && ( [[ $DEBUG ]] && echo " < $BUFFER deleted" );
|
||||||
|
|
||||||
|
kill -INT $LOOP_PID 2>/dev/null;
|
||||||
|
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# (3) Launch INPUT server
|
# (3) Launch INPUT server
|
||||||
|
@ -42,7 +52,7 @@ echo -n "" > $BUFFER;
|
||||||
(
|
(
|
||||||
|
|
||||||
[[ $DEBUG ]] && echo " > binding port $IN_PT to $BUFFER";
|
[[ $DEBUG ]] && echo " > binding port $IN_PT to $BUFFER";
|
||||||
trap "kill -9 $NC_PID 2>/dev/null; exit 1;" HUP INT KILL TERM;
|
trap "kill -9 $NC_PID 2>/dev/null; on_exit;" HUP INT KILL TERM;
|
||||||
|
|
||||||
infail=0;
|
infail=0;
|
||||||
|
|
||||||
|
@ -72,18 +82,6 @@ echo -n "" > $BUFFER;
|
||||||
)&
|
)&
|
||||||
LOOP_PID=$!;
|
LOOP_PID=$!;
|
||||||
|
|
||||||
|
|
||||||
# (2) Remove buffer + kill loop #
|
|
||||||
on_exit(){
|
|
||||||
[[ $DEBUG ]] && echo " < closing binding port $IN_PT to $BUFFER";
|
|
||||||
rm $BUFFER 2>/dev/null && ( [[ $DEBUG ]] && echo " < $BUFFER deleted" );
|
|
||||||
|
|
||||||
kill -INT $LOOP_PID 2>/dev/null;
|
|
||||||
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
trap "on_exit;" HUP INT KILL TERM;
|
trap "on_exit;" HUP INT KILL TERM;
|
||||||
|
|
||||||
wait $LOOP_PID;
|
echo -n "$LOOP_PID";
|
||||||
|
|
||||||
on_exit;
|
|
23
bind-output
23
bind-output
|
@ -34,6 +34,15 @@ BUFFER="/tmp/outbuf_$OUT_ID";
|
||||||
# test -f $BUFFER && rm $BUFFER;
|
# test -f $BUFFER && rm $BUFFER;
|
||||||
echo -n "" > $BUFFER;
|
echo -n "" > $BUFFER;
|
||||||
|
|
||||||
|
# (3) Remove buffer + kill loop #
|
||||||
|
on_exit(){
|
||||||
|
[[ $DEBUG ]] && echo " < closing binding from $BUFFER to $OUT_IP:$OUT_PT";
|
||||||
|
rm $BUFFER 2>/dev/null && ( [[ $DEBUG ]] && echo " < $BUFFER deleted" );
|
||||||
|
|
||||||
|
kill -INT $LOOP_PID 2>/dev/null;
|
||||||
|
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +50,7 @@ echo -n "" > $BUFFER;
|
||||||
#--------------------------------------------------------#
|
#--------------------------------------------------------#
|
||||||
(
|
(
|
||||||
[[ $DEBUG ]] && echo " > binding $BUFFER to $OUT_IP:$OUT_PT";
|
[[ $DEBUG ]] && echo " > binding $BUFFER to $OUT_IP:$OUT_PT";
|
||||||
trap "kill -9 $NC_PID 2>/dev/null; exit 1;" HUP INT KILL TERM;
|
trap "kill -9 $NC_PID 2>/dev/null; on_exit;" HUP INT KILL TERM;
|
||||||
|
|
||||||
outfail=0;
|
outfail=0;
|
||||||
|
|
||||||
|
@ -72,17 +81,7 @@ echo -n "" > $BUFFER;
|
||||||
LOOP_PID=$!;
|
LOOP_PID=$!;
|
||||||
|
|
||||||
|
|
||||||
# (2) Remove buffer + kill loop #
|
|
||||||
on_exit(){
|
|
||||||
[[ $DEBUG ]] && echo " < closing binding from $BUFFER to $OUT_IP:$OUT_PT";
|
|
||||||
rm $BUFFER 2>/dev/null && ( [[ $DEBUG ]] && echo " < $BUFFER deleted" );
|
|
||||||
|
|
||||||
kill -INT $LOOP_PID 2>/dev/null;
|
|
||||||
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
trap "on_exit;" HUP INT KILL TERM;
|
trap "on_exit;" HUP INT KILL TERM;
|
||||||
|
|
||||||
wait $LOOP_PID;
|
echo -n "$LOOP_PID";
|
||||||
|
|
||||||
on_exit;
|
|
Loading…
Reference in New Issue