aboutsummaryrefslogtreecommitdiff
path: root/src/rc
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-02-28 21:47:45 +0000
committerRoy Marples <roy@marples.name>2008-02-28 21:47:45 +0000
commitfcf27783176389af0ee1ca89d2a2495d4e1bfe62 (patch)
tree8752d6a9479a6aabfea56ec3e8739c6ee9af4640 /src/rc
parent391d8de6222c87d423622265d02a224ea9d353ef (diff)
Don't leak fd's.
Diffstat (limited to 'src/rc')
-rw-r--r--src/rc/rc-logger.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 73446083..3e02a1aa 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -169,6 +169,12 @@ void rc_logger_open (const char *level)
if (openpty (&rc_logger_tty, &slave_tty, NULL, &tt, &ws))
return;
+ if ((s = fcntl (rc_logger_tty, F_GETFD, 0)) == 0)
+ fcntl (rc_logger_tty, F_SETFD, s | FD_CLOEXEC);
+
+ if ((s = fcntl (slave_tty, F_GETFD, 0)) == 0)
+ fcntl (slave_tty, F_SETFD, s | FD_CLOEXEC);
+
rc_logger_pid = fork ();
switch (rc_logger_pid) {
case -1:
@@ -249,6 +255,11 @@ void rc_logger_open (const char *level)
setpgid (rc_logger_pid, 0);
fd_stdout = dup (STDOUT_FILENO);
fd_stderr = dup (STDERR_FILENO);
+ if ((s = fcntl (fd_stdout, F_GETFD, 0)) == 0)
+ fcntl (fd_stdout, F_SETFD, s | FD_CLOEXEC);
+
+ if ((s = fcntl (fd_stderr, F_GETFD, 0)) == 0)
+ fcntl (fd_stderr, F_SETFD, s | FD_CLOEXEC);
dup2 (slave_tty, STDOUT_FILENO);
dup2 (slave_tty, STDERR_FILENO);
if (slave_tty != STDIN_FILENO &&