Skip to content

Commit 9f00584

Browse files
aescolarkartben
authored andcommitted
drivers eth_native_tap: Set socket to be closed on exec
If the process does an exec() (or fork, or..) all descriptors are kept open by default, unless O_CLOEXEC is set when opening them. This is usefull for stdin/out/err so that new process is connected to them, but it is very rare for it to be usefull for any other descriptor. In general this leads to descriptors being kept open unnecessarily, which either will block other process from getting them (for example if the child survives the parent but it does something else). Or for a "leak" which unnecessarily uses descriptors and memory in the child process. Let's ensure we do not leak it for this component as we do not need it. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent d91565c commit 9f00584

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/ethernet/eth_native_tap_adapt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int eth_iface_create(const char *dev_name, const char *if_name, bool tun_only)
4444
struct ifreq ifr;
4545
int fd, ret = -EINVAL;
4646

47-
fd = open(dev_name, O_RDWR);
47+
fd = open(dev_name, O_RDWR | O_CLOEXEC);
4848
if (fd < 0) {
4949
return -errno;
5050
}

0 commit comments

Comments
 (0)