diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2015-10-08 11:22:13 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2015-10-08 11:22:13 +0200 |
commit | 17b72a447b7524e66729d31d598ba473bbda7324 (patch) | |
tree | 216012f251ee0b8179f743719ec98513912a883b /nlplug-findfs.c | |
parent | 68f3f4c54fca41b2e59a82ec6e21d12d6d4e9648 (diff) | |
download | mkinitfs-17b72a447b7524e66729d31d598ba473bbda7324.tar.bz2 mkinitfs-17b72a447b7524e66729d31d598ba473bbda7324.tar.xz |
nlplug-findfs: clean up netlink socket
we set CLOEXEC with socket create
Diffstat (limited to 'nlplug-findfs.c')
-rw-r--r-- | nlplug-findfs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nlplug-findfs.c b/nlplug-findfs.c index 100141a..d4ef606 100644 --- a/nlplug-findfs.c +++ b/nlplug-findfs.c @@ -6,6 +6,10 @@ * Copyright (c) 2015 Natanael Copa <ncopa@alpinelinux.org> */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include <dirent.h> #include <err.h> #include <errno.h> @@ -121,7 +125,8 @@ static int init_netlink_socket(void) nls.nl_pid = getpid(); nls.nl_groups = -1; - fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); + fd = socket(PF_NETLINK, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, + NETLINK_KOBJECT_UEVENT); if (fd < 0) err(1, "socket"); @@ -141,7 +146,6 @@ static int init_netlink_socket(void) if (bind(fd, (void *)&nls, sizeof(nls))) err(1, "bind"); - fcntl(fd, F_SETFD, FD_CLOEXEC); return fd; } |