Here is a patch (revised 29Aug01 so that the -T option works correctly) to OpenSSH-2.9p2 to fix the hang-on-exit bug on Linux. To date, no data loss has been reported under Linux with this patch: it does not appear to break ssh or scp, unlike previous related patches. However, data loss has been reported with this patch on HP-UX and OpenBSD, so DO NOT apply it on those systems. Under Linux, this patch
Of these three tests, Openssh-2.9p2 only passes the second one. Markus Friedl has recently developed this patch to fix the third problem; both it and the exit-delay patch below are already contained in the above hang-on-exit patch for Linux systems.
You probably should also install this remote-port-forwarding patch to make the -R option work correctly in OpenSSH-2.9p2.
Here is a patch (revised 29Aug01 so that the -T option works correctly) to add an exit delay to Openssh-2.9p2 for use in tunneling; it allows you to say:
ssh -n -S 30 -L 110:popserver:110 popserver exit &
ssh -N -S 30 -L 110:popserver:110 popserver &
This will wait 30 seconds for the last TCP session on port 110 to close, before exiting the ssh tunneling session. More information is contained in the patch header.