From f5fc5561be15f1b353a29e99679783878ed7503f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Thu, 20 Feb 2014 11:56:46 +0100 Subject: Change set_close_on_exec to take a file descriptor. * Since it's easier to get a fd from a FILE * rather than the other way around. --- src/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 44dec8e..9a791ad 100644 --- a/src/main.c +++ b/src/main.c @@ -365,12 +365,11 @@ print_help (void) #endif void -set_close_on_exec (FILE *fd) +set_close_on_exec (int fd) { - int fnum = fileno (fd); - int flags = fcntl (fnum, F_GETFD); + int flags = fcntl (fd, F_GETFD); if (flags >= 0) - fcntl (fnum, F_SETFD, flags | FD_CLOEXEC); + fcntl (fd, F_SETFD, flags | FD_CLOEXEC); } void @@ -451,7 +450,7 @@ read_startup_files (char *alt_rcfile) if (fileptr) { - set_close_on_exec(fileptr); + set_close_on_exec (fileno (fileptr)); read_rc_file (fileptr); fclose (fileptr); } -- cgit v1.2.3