On 08/09/2025 23:37, Collin Funk wrote:
Pádraig Brady <[email protected]> writes:

We restore the original umask before the exec,
so this umask() is only ensuring u+rw aren't set in the umask
so that we create nohup.out with u+rw.
The simplest way to do that I think is just clearing the umask:

index d58fcc53f..6218986cb 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -141,7 +141,7 @@ main (int argc, char **argv)
        char const *file = "nohup.out";
        int flags = O_CREAT | O_WRONLY | O_APPEND;
        mode_t mode = S_IRUSR | S_IWUSR;
-      mode_t umask_value = umask (~mode);
+      mode_t umask_value = umask (0);
        out_fd = (redirecting_stdout
                  ? fd_reopen (STDOUT_FILENO, file, flags, mode)
                  : open (file, flags, mode));

That rational sounds good to me. Since the umask is only set for the
current process and it is restored before we do exec, setting it to 0 is
fine.

Grisha and I were overthinking it a bit, I think. :)

OK I pushed that with a test and NEWS 
at:https://github.com/coreutils/coreutils/commit/2ed207cb1
cheers,
Padraig

Reply via email to