Dear Maintainer,
Given
strace -foss nohup echo zupa 2>&-
nothing happens, and exits 125 (??).
strace output shows that this is because nohup, per spec,
writes "appending to nohup.out", then notices, then gives up:
-- >8 --
11300 execve("/bin/nohup", ["nohup", "echo", "zupa"], 0xff9d047c /* 24 vars */) = 0
11300 brk(NULL) = 0x1822000
11300 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf7efd000
11300 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
11300 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 2
11300 newfstatat(2, "", {st_mode=S_IFREG|0644, st_size=29987, ...}, AT_EMPTY_PATH) = 0
11300 mmap(NULL, 29987, PROT_READ, MAP_PRIVATE, 2, 0) = 0xf7ef5000
11300 close(2) = 0
11300 openat(AT_FDCWD, "/lib/x86_64-linux-gnux32/libc.so.6", O_RDONLY|O_CLOEXEC) = 2
11300 read(2, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\251\1\0004\0\0\0"..., 512) = 512
11300 pread64(2, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\27\345\33\301\6t+\fM\20\230)p\213*i"..., 96, 468) = 96
11300 newfstatat(2, "", {st_mode=S_IFREG|0755, st_size=1848656, ...}, AT_EMPTY_PATH) = 0
11300 mmap(NULL, 1878332, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 2, 0) = 0xf7d2a000
11300 mprotect(0xf7d43000, 1732608, PROT_NONE) = 0
11300 mmap(0xf7d43000, 1400832, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 2, 0x19000) = 0xf7d43000
11300 mmap(0xf7e99000, 327680, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 2, 0x16f000) = 0xf7e99000
11300 mmap(0xf7eea000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 2, 0x1bf000) = 0xf7eea000
11300 mmap(0xf7eed000, 31036, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xf7eed000
11300 close(2) = 0
11300 arch_prctl(ARCH_SET_FS, 0xf7efe240) = 0
11300 mprotect(0xf7eea000, 8192, PROT_READ) = 0
11300 mprotect(0x408000, 4096, PROT_READ) = 0
11300 mprotect(0xf7f2d000, 8192, PROT_READ) = 0
11300 munmap(0xf7ef5000, 29987) = 0
11300 brk(NULL) = 0x1822000
11300 brk(0x1843000) = 0x1843000
11300 brk(0x1844000) = 0x1844000
11300 openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 2
11300 newfstatat(2, "", {st_mode=S_IFREG|0644, st_size=3041504, ...}, AT_EMPTY_PATH) = 0
11300 mmap(NULL, 2097152, PROT_READ, MAP_PRIVATE, 2, 0) = 0xf7b2a000
11300 mmap(NULL, 2596864, PROT_READ, MAP_PRIVATE, 2, 0x6d000) = 0xf78b0000
11300 close(2) = 0
11300 ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
11300 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
11300 ioctl(2, TCGETS, 0xff956b40) = -1 EBADF (Bad file descriptor)
11300 openat(AT_FDCWD, "/dev/null", O_WRONLY) = 2
11300 dup2(2, 0) = 0
11300 close(2) = 0
11300 umask(0177177) = 022
11300 openat(AT_FDCWD, "nohup.out", O_WRONLY|O_CREAT|O_APPEND, 0600) = 2
11300 dup2(2, 1) = 1
11300 close(2) = 0
11300 umask(022) = 0177
11300 openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 2
11300 newfstatat(2, "", {st_mode=S_IFREG|0644, st_size=2996, ...}, AT_EMPTY_PATH) = 0
11300 read(2, "# Locale name alias data base.\n#"..., 4096) = 2996
11300 read(2, "", 4096) = 0
11300 close(2) = 0
11300 openat(AT_FDCWD, "/usr/share/locale/en_GB.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
11300 openat(AT_FDCWD, "/usr/share/locale/en_GB.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
11300 openat(AT_FDCWD, "/usr/share/locale/en_GB/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
11300 openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
11300 openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
11300 openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
11300 write(2, "nohup: ", 7) = -1 EBADF (Bad file descriptor)
11300 write(2, "ignoring input and appending out"..., 50) = -1 EBADF (Bad file descriptor)
11300 write(2, "\n", 1) = -1 EBADF (Bad file descriptor)
11300 close(1) = 0
11300 close(2) = -1 EBADF (Bad file descriptor)
11300 exit_group(125) = ?
11300 +++ exited with 125 +++
-- >8 --
This is wrong per POSIX 1002.1 Issue 7:
DESCRIPTION
If the standard output is a terminal, all output written by the
named utility to its standard output shall be appended to the end of
the file nohup.out in the current directory. If nohup.out cannot be
created or opened for appending, the output shall be appended to the
end of the file nohup.out in the directory specified by the HOME
environment variable. If neither file can be created or opened for
appending, utility shall not be invoked.
EXIT STATUS
The following exit values shall be returned:
126 The utility specified by utility was found
but could not be invoked.
127 An error occurred in the nohup utility
or the utility specified by utility could not be found.
Otherwise, the exit status of nohup shall be that
of the utility specified by the utility operand.
Even ignoring the globally broken coreutils exit codes,
while this does technically count as "difficulties in [...] writing
files", not being able to write a status message is neither
unrecoverable, nor in any way critical. Silently giving up
is just in bad taste, especially considering that nohup explicitly
handles closed standard I/O streams.
наб