diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-01-13 12:38:26 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-01-13 12:38:26 +0400 |
commit | bf1ccc7f6e7a9dc5a8ba3d8d02b25ad446458840 (patch) | |
tree | 4e53a7f2990e40436f6ae98434f72c3db14434c0 /accel-pppd/logs | |
parent | 03a466f1b0f7549c2ef89c1e544c2c86c3958ad4 (diff) | |
download | accel-ppp-bf1ccc7f6e7a9dc5a8ba3d8d02b25ad446458840.tar.gz accel-ppp-bf1ccc7f6e7a9dc5a8ba3d8d02b25ad446458840.zip |
set FD_CLOEXEC on opened file descriptors
Diffstat (limited to 'accel-pppd/logs')
-rw-r--r-- | accel-pppd/logs/log_file.c | 4 | ||||
-rw-r--r-- | accel-pppd/logs/log_tcp.c | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/accel-pppd/logs/log_file.c b/accel-pppd/logs/log_file.c index f1a5018..48f4351 100644 --- a/accel-pppd/logs/log_file.c +++ b/accel-pppd/logs/log_file.c @@ -106,6 +106,8 @@ static int log_file_open(struct log_file_t *lf, const char *fname) return -1; } + fcntl(lf->fd, F_SETFD, fcntl(lf->fd, F_GETFD) | FD_CLOEXEC); + lf->offset = lseek(lf->fd, 0, SEEK_END); return 0; @@ -412,6 +414,7 @@ static void fail_reopen(void) log_emerg("log_file: open '%s': %s\n", fname, strerror(errno)); return; } + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); fail_log_file->new_fd = fd; } @@ -424,6 +427,7 @@ static void general_reopen(void) log_emerg("log_file: open '%s': %s\n", fname, strerror(errno)); return; } + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); log_file->new_fd = fd; } diff --git a/accel-pppd/logs/log_tcp.c b/accel-pppd/logs/log_tcp.c index ceaeb1c..3f76ff8 100644 --- a/accel-pppd/logs/log_tcp.c +++ b/accel-pppd/logs/log_tcp.c @@ -210,6 +210,8 @@ static void start_connect(struct tcp_target_t *t) return; } + fcntl(t->hnd.fd, F_SETFD, fcntl(t->hnd.fd, F_GETFD) | FD_CLOEXEC); + if (fcntl(t->hnd.fd, F_SETFL, O_NONBLOCK)) { log_emerg("log-tcp: failed to set nonblocking mode: %s\n", strerror(errno)); close(t->hnd.fd); |