瀏覽代碼

Set close-on-exec in attempt to head off GitHub issue #61

Adam Ierymenko 11 年之前
父節點
當前提交
6c5f6feb5e
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      node/UnixEthernetTap.cpp

+ 6 - 0
node/UnixEthernetTap.cpp

@@ -308,6 +308,9 @@ UnixEthernetTap::UnixEthernetTap(
 
 
 	::close(sock);
 	::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);
 	::pipe(_shutdownSignalPipe);
 
 
 	TRACE("tap %s created",_dev.c_str());
 	TRACE("tap %s created",_dev.c_str());
@@ -418,6 +421,9 @@ UnixEthernetTap::UnixEthernetTap(
 
 
 	_setIpv6Stuff(_dev.c_str(),true,false);
 	_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);
 	::pipe(_shutdownSignalPipe);
 
 
 	_thread = Thread::start(this);
 	_thread = Thread::start(this);