From 6c5f6feb5ebd4e92d9b7f49eb50e05b3b7d01441 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 9 Apr 2014 15:22:08 -0700 Subject: [PATCH] Set close-on-exec in attempt to head off GitHub issue #61 --- node/UnixEthernetTap.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node/UnixEthernetTap.cpp b/node/UnixEthernetTap.cpp index 50f1dcc53..240efe410 100644 --- a/node/UnixEthernetTap.cpp +++ b/node/UnixEthernetTap.cpp @@ -308,6 +308,9 @@ UnixEthernetTap::UnixEthernetTap( ::close(sock); + // Set close-on-exec so that devices cannot persist if we fork/exec for update + fcntl(_fd,F_SETFD,fcntl(_fd,F_GETFD) | FD_CLOEXEC); + ::pipe(_shutdownSignalPipe); TRACE("tap %s created",_dev.c_str()); @@ -418,6 +421,9 @@ UnixEthernetTap::UnixEthernetTap( _setIpv6Stuff(_dev.c_str(),true,false); + // Set close-on-exec so that devices cannot persist if we fork/exec for update + fcntl(_fd,F_SETFD,fcntl(_fd,F_GETFD) | FD_CLOEXEC); + ::pipe(_shutdownSignalPipe); _thread = Thread::start(this);