Skip to content

Commit d83ebce

Browse files
aescolarkartben
authored andcommitted
drivers/serial/uart_native_tty: Set TTY 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 07987cc commit d83ebce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/serial/uart_native_tty_bottom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ int native_tty_poll_bottom(int fd)
267267

268268
int native_tty_open_tty_bottom(const char *pathname)
269269
{
270-
int fd = open(pathname, O_RDWR | O_NOCTTY);
270+
int fd = open(pathname, O_RDWR | O_NOCTTY | O_CLOEXEC);
271271

272272
if (fd < 0) {
273273
ERROR("Failed to open serial port %s, errno: %i\n", pathname, errno);

0 commit comments

Comments
 (0)