Skip to content

Commit d91565c

Browse files
aescolarkartben
authored andcommitted
drivers eeprom_simulator_native: Set EEPROM file to close 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 01118e2 commit d91565c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/eeprom/eeprom_simulator_native.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int eeprom_mock_init_native(bool eeprom_in_ram, char **mock_eeprom, unsigned int
4646
return -1;
4747
}
4848
} else {
49-
*eeprom_fd = open(eeprom_file_path, O_RDWR | O_CREAT, (mode_t)0600);
49+
*eeprom_fd = open(eeprom_file_path, O_RDWR | O_CREAT | O_CLOEXEC, (mode_t)0600);
5050
if (*eeprom_fd == -1) {
5151
nsi_print_warning("Failed to open EEPROM device file %s: %s\n",
5252
eeprom_file_path, strerror(errno));

0 commit comments

Comments
 (0)