[PATCH 7/7] trace-cmd record: Fix stdin redirection to /dev/null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <jmarchan@xxxxxxxxxx>
---
 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





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux