From 590f0f85e05f5fb528b067631f71cb7b144c1dee Mon Sep 17 00:00:00 2001 From: Kemal Zebari Date: Wed, 19 Jul 2023 14:54:07 -0700 Subject: [PATCH] nohup: Don't leak fd used to open nohup.out Since we may redirect stdout, stderr, or both to the file description referring to the nohup.out file, there is no need to keep the fd that created that file description around. --- Userland/Utilities/nohup.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Utilities/nohup.cpp b/Userland/Utilities/nohup.cpp index fda664965e..45eea5e385 100644 --- a/Userland/Utilities/nohup.cpp +++ b/Userland/Utilities/nohup.cpp @@ -44,6 +44,8 @@ void dup_out_file(int fd_to_redirect) exit(127); } + MUST(Core::System::close(fd)); + if (fd_to_redirect != STDERR_FILENO) outln(stderr, "appending output to {}", path); }