Added option for 'read' not to flush buffer (with '-' as 2nd argument) + now 'launch' removes buffers in /tmp
This commit is contained in:
parent
08f30d2996
commit
e84678ac6b
7
launch
7
launch
|
@ -114,8 +114,8 @@ echo -e "#!/bin/bash\nBUF_IN=\"$BUF_IN\"; BUF_OUT=\"$BUF_OUT\";\nIN_PID=$IN_PID;
|
||||||
# (6) Manage ending proccess
|
# (6) Manage ending proccess
|
||||||
#--------------------------------------------------------#
|
#--------------------------------------------------------#
|
||||||
# (1) Kill subproccesses if Ctrl+C #
|
# (1) Kill subproccesses if Ctrl+C #
|
||||||
trap "kill -9 $OUT_PID 2>/dev/null; kill -9 $IN_PIT 2>/dev/null; rm $ROOT/config_$1; pkill nc 2>/dev/null;" INT;
|
trap "kill -9 $OUT_PID 2>/dev/null; kill -9 $IN_PIT 2>/dev/null; rm $ROOT/config_$1; pkill nc 2>/dev/null; rm $BUF_OUT; rm $BUF_IN; exit 1;" INT;
|
||||||
trap "kill -9 $OUT_PID 2>/dev/null; kill -9 $IN_PIT 2>/dev/null; rm $ROOT/config_$1; pkill nc 2>/dev/null;" KILL;
|
trap "kill -9 $OUT_PID 2>/dev/null; kill -9 $IN_PIT 2>/dev/null; rm $ROOT/config_$1; pkill nc 2>/dev/null; rm $BUF_OUT; rm $BUF_IN; exit 1;" KILL;
|
||||||
|
|
||||||
# (2) Wait for daemons to stop #
|
# (2) Wait for daemons to stop #
|
||||||
wait $OUT_PID;
|
wait $OUT_PID;
|
||||||
|
@ -125,4 +125,7 @@ pkill nc 2>/dev/null;
|
||||||
# (3) Remove config file #
|
# (3) Remove config file #
|
||||||
rm $ROOT/config_$1;
|
rm $ROOT/config_$1;
|
||||||
|
|
||||||
|
# (4) Remove buffers #
|
||||||
|
rm $BUF_OUT;
|
||||||
|
rm $BUF_IN;
|
||||||
|
|
||||||
|
|
6
read
6
read
|
@ -6,6 +6,10 @@ ROOT=$(dirname `realpath $0`);
|
||||||
# (1) Check arguments
|
# (1) Check arguments
|
||||||
test $# -lt 1 && echo "ERR: Missing arguments (name)" && exit 1;
|
test $# -lt 1 && echo "ERR: Missing arguments (name)" && exit 1;
|
||||||
|
|
||||||
|
# (2) Manage optional argument #
|
||||||
|
FLUSH=1;
|
||||||
|
test $# -ge 2 -a "$2" = "-" && FLUSH=0;
|
||||||
|
|
||||||
# (2) load configuration file
|
# (2) load configuration file
|
||||||
test -f $ROOT/config_$1 && source $ROOT/config_$1 || ( echo "ERR: No such name" && exit 1 ) || exit 1;
|
test -f $ROOT/config_$1 && source $ROOT/config_$1 || ( echo "ERR: No such name" && exit 1 ) || exit 1;
|
||||||
|
|
||||||
|
@ -13,4 +17,4 @@ test -f $ROOT/config_$1 && source $ROOT/config_$1 || ( echo "ERR: No such name"
|
||||||
cat $BUF_IN;
|
cat $BUF_IN;
|
||||||
|
|
||||||
# (4) Flush buffer
|
# (4) Flush buffer
|
||||||
echo -ne "" > $BUF_IN;
|
test $FLUSH -eq 1 && echo -ne "" > $BUF_IN;
|
||||||
|
|
Loading…
Reference in New Issue