ref: 17b72a447b7524e66729d31d598ba473bbda7324
parent: 68f3f4c54fca41b2e59a82ec6e21d12d6d4e9648
author: Natanael Copa <ncopa@alpinelinux.org>
date: Thu Oct 8 06:22:13 CDT 2015
nlplug-findfs: clean up netlink socket we set CLOEXEC with socket create
--- 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 @@
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 @@
if (bind(fd, (void *)&nls, sizeof(nls)))
err(1, "bind");
- fcntl(fd, F_SETFD, FD_CLOEXEC);
return fd;
}