tun: Kill the tunnel script's process group
authorKevin Cernekee <cernekee@gmail.com>
Wed, 14 Nov 2012 03:00:25 +0000 (19:00 -0800)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 14 Nov 2012 10:09:33 +0000 (10:09 +0000)
commit2f9fa7cc11e1d643067c6c53487ddb8087d96239
treef776ab63e565d0eb2a091b042b43040ee2f34e01
parent4bde16100ba05b162cf24311b4a77b34860c577b
tun: Kill the tunnel script's process group

When invoked with --script-tun, openconnect starts the tunnel script
via "/bin/sh -c 'SCRIPT'", then sends SIGHUP to the shell's PID when
shutting down.  However, non-interactive shells are not guaranteed to
send SIGHUP to any running jobs¹; indeed, the observed behavior on
Linux is that only the shell process receives SIGHUP, and the tunnel
script continues running after openconnect exits.

A quick fix is to set the child's pgid == pid, then send SIGHUP to the
entire process group when we want to shut down.

¹ http://www.gnu.org/software/bash/manual/html_node/Signals.html

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
tun.c