Skip to content

Commit

Permalink
* misc/syslog.c (openlog_internal): Use SOCK_CLOEXEC if possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Jul 26, 2008
1 parent 72112b0 commit c0216df
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
2008-07-26 Ulrich Drepper <drepper@redhat.com>

* misc/syslog.c (openlog_internal): Use SOCK_CLOEXEC if possible.

* malloc/mtrace.c (mtrace): Use 'e' flag in fopen call. Drop
F_SETFD use if we know fopen set the flag.

Expand Down
31 changes: 28 additions & 3 deletions misc/syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,35 @@ openlog_internal(const char *ident, int logstat, int logfac)
(void)strncpy(SyslogAddr.sun_path, _PATH_LOG,
sizeof(SyslogAddr.sun_path));
if (LogStat & LOG_NDELAY) {
if ((LogFile = __socket(AF_UNIX, LogType, 0))
== -1)
#ifdef SOCK_CLOEXEC
# ifndef __ASSUME_SOCK_CLOEXEC
if (__have_sock_cloexec >= 0) {
# endif
LogFile = __socket(AF_UNIX,
LogType
| SOCK_CLOEXEC, 0);
# ifndef __ASSUME_SOCK_CLOEXEC
if (__have_sock_cloexec == 0)
__have_sock_cloexec
= (LogFile != -1
|| errno != EINVAL);
#endif
}
#endif
#ifndef __ASSUME_SOCK_CLOEXEC
# ifdef SOCK_CLOEXEC
if (__have_sock_cloexec < 0)
# endif
LogFile = __socket(AF_UNIX, LogType, 0);
#endif
if (LogFile == -1)
return;
(void)__fcntl(LogFile, F_SETFD, 1);
#ifndef __ASSUME_SOCK_CLOEXEC
# ifdef SOCK_CLOEXEC
if (__have_sock_cloexec < 0)
# endif
__fcntl(LogFile, F_SETFD, FD_CLOEXEC);
#endif
}
}
if (LogFile != -1 && !connected)
Expand Down

0 comments on commit c0216df

Please sign in to comment.