Isaac Schwabacher wrote:
This is confusing at best
Yes, at the very least the documentation should be improved. I installed the attached patch to try to do that.
Is it really better for a read on stdin to fail with EBADF rather than simply returning EOF
It depends on whether we want GNU nohup to be a universal donor or a universal acceptor. Right now it's more the former (if a program works with GNU nohup it should be portable to other nohup platforms); a nohup that makes stdin read from /dev/null would be more "accepting" of badly-written code developed elsewhere. I suppose I could be talked into that, particularly given Matlab's misbehavior here. Jim?
>From 666dec6b34e1204b173672f9bad47f34cd8bad3f Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 27 Mar 2015 15:01:35 -0700 Subject: [PATCH] nohup: clarify stdin redirection Problem reported by Isaac Schwabacher in: http://bugs.gnu.org/20214 * doc/coreutils.texi (nohup invocation): Clarify that when nohup's stdin gets redirected, it's unreadable. * doc/coreutils.texi (nohup invocation): * src/nohup.c (usage): Don't promise /dev/null. --- doc/coreutils.texi | 13 +++++++------ src/nohup.c | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 6110cec..3cbce63 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -16714,12 +16714,13 @@ out. Synopsis: nohup @var{command} [@var{arg}]@dots{} @end example -If standard input is a terminal, it is redirected from -@file{/dev/null} so that terminal sessions do not mistakenly consider -the terminal to be used by the command. This is a GNU -extension; programs intended to be portable to non-GNU hosts -should use @samp{nohup @var{command} [@var{arg}]@dots{} </dev/null} -instead. +If standard input is a terminal, redirect it so that terminal sessions +do not mistakenly consider the terminal to be used by the command. +Make the substitute file descriptor unreadable, so that commands that +mistakenly attempt to read from standard input can report an error. +This redirection is a GNU extension; programs intended to be portable +to non-GNU hosts can use @samp{nohup @var{command} [@var{arg}]@dots{} +0>/dev/null} instead. @flindex nohup.out If standard output is a terminal, the command's standard output is appended diff --git a/src/nohup.c b/src/nohup.c index 9bc8686..8cdaced 100644 --- a/src/nohup.c +++ b/src/nohup.c @@ -63,7 +63,7 @@ Run COMMAND, ignoring hangup signals.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (_("\n\ -If standard input is a terminal, redirect it from /dev/null.\n\ +If standard input is a terminal, redirect it from an unreadable file.\n\ If standard output is a terminal, append output to 'nohup.out' if possible,\n\ '$HOME/nohup.out' otherwise.\n\ If standard error is a terminal, redirect it to standard output.\n\ -- 2.1.0
