mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
nohup now redirects a tty stdin to an unreadable fd instead of closing it.
This commit is contained in:
1 parent
3d8bc90af3
commit
8597e1fd2d
4 files changed
+34
-9
No files matched your search
@@ -1,7 +1,14 @@
|
||||
2005-05-26 Jim Meyering <jim@meyering.net>
|
||||
2005-05-26 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* Version 5.3.1.
|
||||
|
||||
* NEWS: nohup now redirects a tty stdin to an unreadable fd
|
||||
instead of closing it.
|
||||
* doc/coreutils.texi (nohup invocation): Document this.
|
||||
* src/nohup.c (main): Implement this.
|
||||
|
||||
2005-05-26 Jim Meyering <jim@meyering.net>
|
||||
|
||||
* src/expr.c (toarith): Fix a sign error introduced on 2005-01-14.
|
||||
Reported by David Alan Gilbert.
|
||||
* tests/expr/basic: Add tests using arithmetic on negative integers.
|
||||
|
||||
@@ -143,7 +143,8 @@ GNU coreutils NEWS -*- outline -*-
|
||||
join now supports a NUL field separator, e.g., "join -t '\0'".
|
||||
join now detects and reports incompatible options, e.g., "join -t x -t y",
|
||||
|
||||
nohup now closes stdin if it is a terminal, unless POSIXLY_CORRECT is set.
|
||||
If stdin is a terminal, nohup now closes it and then reopens it with an
|
||||
unreadable file descriptor. (This step is skipped if POSIXLY_CORRECT is set.)
|
||||
This prevents the command from tying up an OpenSSH session after you logout.
|
||||
|
||||
stat -f -c %S outputs the fundamental block size (used for block counts).
|
||||
|
||||
+3
-1
@@ -12571,7 +12571,9 @@ descriptor as the (possibly-redirected) standard output.
|
||||
@vindex POSIXLY_CORRECT
|
||||
If standard input is a terminal, it is closed so that terminal
|
||||
sessions do not mistakenly consider the terminal to be used by the
|
||||
command. However, this step is skipped if @env{POSIXLY_CORRECT} is
|
||||
command. To avoid glitches in poorly-written programs standard input
|
||||
is then reopened with an innocuous file descriptor that cannot be read
|
||||
from. However, these steps are skipped if @env{POSIXLY_CORRECT} is
|
||||
set since @acronym{POSIX} requires standard input to be left alone.
|
||||
|
||||
@command{nohup} does not automatically put the command it runs in the
|
||||
|
||||
+21
-6
@@ -75,6 +75,7 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int saved_stderr_fd = STDERR_FILENO;
|
||||
bool nohup_out = false;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
@@ -96,12 +97,6 @@ main (int argc, char **argv)
|
||||
usage (NOHUP_FAILURE);
|
||||
}
|
||||
|
||||
/* If standard input is a tty, close it. POSIX requires nohup to
|
||||
leave standard input alone, but that's less useful in practice as
|
||||
it causes a "nohup foo & exit" session to hang with OpenSSH. */
|
||||
if (!getenv ("POSIXLY_CORRECT") && isatty (STDIN_FILENO))
|
||||
close (STDIN_FILENO);
|
||||
|
||||
/* If standard output is a tty, redirect it (appending) to a file.
|
||||
First try nohup.out, then $HOME/nohup.out. */
|
||||
if (isatty (STDOUT_FILENO))
|
||||
@@ -143,6 +138,7 @@ main (int argc, char **argv)
|
||||
|
||||
error (0, 0, _("appending output to %s"), quote (file));
|
||||
free (in_home);
|
||||
nohup_out = true;
|
||||
}
|
||||
|
||||
/* If standard error is a tty, redirect it to stdout. */
|
||||
@@ -168,6 +164,25 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* If standard input is a tty, replace it with a file descriptor
|
||||
that exists but gives you an error if you try to read it. POSIX
|
||||
requires nohup to leave standard input alone, but that's less
|
||||
useful in practice as it causes a "nohup foo & exit" session to
|
||||
hang with OpenSSH. */
|
||||
if (!getenv ("POSIXLY_CORRECT") && isatty (STDIN_FILENO))
|
||||
{
|
||||
close (STDIN_FILENO);
|
||||
if (nohup_out)
|
||||
dup (STDOUT_FILENO);
|
||||
else
|
||||
{
|
||||
/* This doesn't give you an error on older systems if you're
|
||||
root, but there's no portable way to fix this and it's
|
||||
not worth worrying about these days. */
|
||||
open ("/", O_RDONLY);
|
||||
}
|
||||
}
|
||||
|
||||
signal (SIGHUP, SIG_IGN);
|
||||
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user