diff options
-rw-r--r-- | python-ethtool/etherinfo.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c index 42973ad..2cebdfb 100644 --- a/python-ethtool/etherinfo.c +++ b/python-ethtool/etherinfo.c @@ -21,6 +21,7 @@ #include <string.h> #include <sys/types.h> #include <unistd.h> +#include <fcntl.h> #include <stdlib.h> #include <asm/types.h> #include <sys/socket.h> @@ -382,6 +383,13 @@ int open_netlink(struct etherinfo_obj_data *data) *data->nlc = nl_handle_alloc(); nl_connect(*data->nlc, NETLINK_ROUTE); if( (*data->nlc != NULL) ) { + /* Force O_CLOEXEC flag on the NETLINK socket */ + if( fcntl(nl_socket_get_fd(*data->nlc), F_SETFD, FD_CLOEXEC) == -1 ) { + fprintf(stderr, + "**WARNING** Failed to set O_CLOEXEC on NETLINK socket: %s\n", + strerror(errno)); + } + /* Tag this object as an active user */ pthread_mutex_lock(&nlc_counter_mtx); (*data->nlc_users)++; |