From e84678ac6b9524a2c8a270f2af88a79a59fd2923 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 28 Jan 2018 16:58:24 +0100 Subject: [PATCH] Added option for 'read' not to flush buffer (with '-' as 2nd argument) + now 'launch' removes buffers in /tmp --- launch | 7 +++++-- read | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/launch b/launch index b76c0a3..1b5a83d 100755 --- a/launch +++ b/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 #--------------------------------------------------------# # (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;" 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;" 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;" KILL; # (2) Wait for daemons to stop # wait $OUT_PID; @@ -125,4 +125,7 @@ pkill nc 2>/dev/null; # (3) Remove config file # rm $ROOT/config_$1; +# (4) Remove buffers # +rm $BUF_OUT; +rm $BUF_IN; diff --git a/read b/read index 05066c8..c0bfc89 100755 --- a/read +++ b/read @@ -6,6 +6,10 @@ ROOT=$(dirname `realpath $0`); # (1) Check arguments 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 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; # (4) Flush buffer -echo -ne "" > $BUF_IN; +test $FLUSH -eq 1 && echo -ne "" > $BUF_IN;