openconnect: openconnect-wrapper would trap signals and send the correct one to server
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 31 Aug 2014 23:09:39 +0000 (01:09 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 31 Aug 2014 23:09:39 +0000 (01:09 +0200)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
net/openconnect/files/openconnect-wrapper

index eb2df54f4fe4f7bf88f1188ddd7b8a78f4d43e52..744e5a5cd00ee22a24ea10623a07757abbd15f86 100755 (executable)
@@ -11,4 +11,21 @@ test -z "$1" && exit 1
 pwfile=$1
 shift
 
-cat $pwfile|/usr/sbin/openconnect $*
+pidfile=/var/run/ocwrap-$$.pid
+
+cleanup()
+{
+       if ! test -z "$pid";then
+               kill $pid
+               wait $pid
+       fi
+       exit 0
+}
+
+trap cleanup 1 2 3 6 15
+
+rm -f "$pidfile"
+/usr/sbin/openconnect $* <$pwfile &
+pid=$!
+
+wait $pid