summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgosher22
1 files changed, 21 insertions, 1 deletions
diff --git a/gosher b/gosher
index b4263c0..a099731 100755
--- a/gosher
+++ b/gosher
@@ -22,6 +22,19 @@
## server...
##
+NETCAT=netcat
+OPREFIX=/tmp/outf_
+IPREFIX=/tmp/inf_
+
+
+## function
+cleanup(){
+ [ -p "${OPREFIX}$$" ] && rm -f ${OPREFIX}$$
+ [ -p "${IPREFIX}$$" ] && rm -f ${IPREFIX}$$
+ exit 1
+
+}
+
MYNAME=$(basename $0)
if [ -z "${MYNAME#gosher}" ]; then
@@ -30,8 +43,15 @@ if [ -z "${MYNAME#gosher}" ]; then
PORT=${1:-70}
GOPHERDIR=${2:-"./"}
+ trap cleanup 0 HUP INT TRAP TERM QUIT
+
while [ 1 -eq 1 ]; do
- netcat -vv -k -l -p ${PORT} -c "./gosher_serve ${GOPHERDIR}"
+ OUTF=${OPREFIX}$$
+ INF=${IPREFIX}$$
+ mkfifo -m 600 $OUTF $INF
+ ./gosher_serve ${GOPHERDIR} <$INF >$OUTF &
+ ${NETCAT} -vv -l -p ${PORT} >$INF <$OUTF
+ rm $OUTF $INF
ret=$?
done
exit 0