POSIX nohup and SSH - Linux

This is a discussion on POSIX nohup and SSH - Linux ; For some time running:
nohup some-job &amp;
logout
causes ssh to hang. It didn't used to when I used telnet
instead. Some research confirmed that ssh (openSSH in
particular) will not close the session if any processes
are still connected ...

POSIX nohup and SSH

For some time running:

nohup some-job &
logout

causes ssh to hang. It didn't used to when I used telnet
instead. Some research confirmed that ssh (openSSH in
particular) will not close the session if any processes
are still connected to the tty. Although patches to
ssh are posted all over the internet, the maintainers,
correctly in my opinion, claim it was telnetd that didn't
work correctly and the current behavior is correct. They
think we should run jobs this way:

nohup some-job
exit

Which will not cause the session to hang.

Thinking about this, I think that the POSIX nohup
definition is based on the assumption of the old
telnetd behavior, which closed the session when the
shell exited, regardless of what other processes
may still be connected.

I read somplace that POSIX is currently being revised
for the next version of the standard. It seems to me
that a simple change to nohup to close stdin, or
redirected from /dev/null would solve the problem.
(A flag/environment variable could be added to restore
the original behavior.)

In fact I have made such a change to the GNU version of
nohup, and it works great. I think this would be a
proper change; either nohup shouldn't handle redirection
at all or it should do it right.

Does Solaris implementation of sshd have this problem?
Is there some standard mailing list or wiki or someplace
more appropriate to discuss this? Does anyone care?

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

/* Written by Jim Meyering */

/* Modified 5/2005 by Wayne Pollock. The change
is to redirect stdin (if a tty) from /dev/null. Rational: OpenSSH
and others work differently than old telnetd did, in that when the
shell closes the session is closed even if some process still has
the connection open for I/O. Dispite requests and posted patches
SSH keeps the session open if any process is attached. This is
proper but it does mean utilities such as nohup are broken, in that
they don't completely redirect terminal input and output.
Future work: get POSIX to update all nohup, and add a flag and/or
environment variable to restore old behavior. */

/* If stderr is on a tty, redirect it to stdout. */
if ((stderr_isatty = isatty (STDERR_FILENO)))
{
/* Save a copy of stderr before redirecting, so we can use the original
if execve fails. It's no big deal if this dup fails. It might
not change anything, and at worst, it'll lead to suppression of
the post-failed-execve diagnostic. */
saved_stderr_fd = dup (STDERR_FILENO);

if (saved_stderr_fd != -1
&& ! set_cloexec_flag (saved_stderr_fd, true))
error (NOHUP_FAILURE, errno,
_("failed to set the copy of stderr to close on exec"));

/* The execve failed. Output a diagnostic to stderr only if:
- stderr was initially redirected to a non-tty, or
- stderr was initially directed to a tty, and we've
just dup2'd it to point back to that same tty.
In other words, output the diagnostic if possible, but not if
it'd go to nohup.out. */
if ( ! stderr_isatty
|| (saved_stderr_fd != -1
&& dup2 (saved_stderr_fd, STDERR_FILENO) != -1))
error (0, saved_errno, _("cannot run command %s"), quote (*cmd));