chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8efe3c0
)
sd-daemon: set FD_CLOEXEC by default
author
Lennart Poettering
<lennart@poettering.net>
Mon, 24 May 2010 16:59:46 +0000
(18:59 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Mon, 24 May 2010 16:59:46 +0000
(18:59 +0200)
src/sd-daemon.c
patch
|
blob
|
history
diff --git
a/src/sd-daemon.c
b/src/sd-daemon.c
index eec4722709cb15f89eaca9ad8e2a8aa64ad75cec..2e1bf3213c100ecf5f3bdfd43298d3f22af383a6 100644
(file)
--- a/
src/sd-daemon.c
+++ b/
src/sd-daemon.c
@@
-28,6
+28,7
@@
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <sys/fcntl.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <errno.h>
@@
-41,7
+42,7
@@
int sd_listen_fds(int unset_environment) {
#ifdef DISABLE_SYSTEMD
return 0;
#else
#ifdef DISABLE_SYSTEMD
return 0;
#else
- int r;
+ int r
, fd
;
const char *e;
char *p = NULL;
unsigned long l;
const char *e;
char *p = NULL;
unsigned long l;
@@
-88,6
+89,24
@@
int sd_listen_fds(int unset_environment) {
goto finish;
}
goto finish;
}
+
+ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {
+ int flags;
+
+ if ((flags = fcntl(fd, F_GETFD)) < 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ if (flags & FD_CLOEXEC)
+ continue;
+
+ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
+ r = -errno;
+ goto finish;
+ }
+ }
+
r = (int) l;
finish:
r = (int) l;
finish: