[PATCH 7/7] trace-cmd record: Fix stdin redirection to /dev/null
"Jerome Marchand" <[email protected]> Thu, 5 Dec 2024 15:44:39 +0100
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
In daemonize_start(), stdin file descriptor is closed after the call to dup2. This doesn't make sense and could lead to FD zero being reused. I assume the original intend was to close the devnull FD which in the current code remains opened while the devnull variable goes out of scope. Close devnull instead of 0. Signed-off-by: Jerome Marchand <[email protected]> --- tracecmd/trace-record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 6e9b4535..fe9ceaa8 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -1677,7 +1677,7 @@ static void daemonize_start(void) if (devnull > 0) { if (dup2(devnull, 0) == -1) die("daemonize: dup2"); - close(0); + close(devnull); } return; -- 2.47.0