Skip to content

Commit b850715

Browse files
aescolarkartben
authored andcommitted
drivers/net/nsos: 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 19b181e commit b850715

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/nsos_adapt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ int nsos_adapt_socket(int family_mid, int type_mid, int proto_mid)
269269
return ret;
270270
}
271271

272-
ret = socket(family, type, proto);
272+
ret = socket(family, type | SOCK_CLOEXEC, proto);
273273
if (ret < 0) {
274274
return -nsi_errno_to_mid(errno);
275275
}

0 commit comments

Comments
 (0)