drivers/input/linux_evdev: Close input file 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 <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
committed by
Benjamin Cabé
parent
e5d6e0ce24
commit
19b181e58e
@@ -42,7 +42,7 @@ int linux_evdev_open(const char *path)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(path, O_RDONLY | O_NONBLOCK);
|
||||
fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
nsi_print_error_and_exit(
|
||||
"Failed to open the evdev device %s: %s\n",
|
||||
|
||||
Reference in New Issue
Block a user