Skip to content

Commit 07ac287

Browse files
committed
boards native_sim: reboot: Do not close descriptors manually
Instead rely on them having been opened with O_CLOEXIT Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent 730efd9 commit 07ac287

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

boards/native/native_sim/reboot_bottom.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,6 @@
1717

1818
static const char module[] = "native_sim_reboot";
1919

20-
static long close_open_fds(void)
21-
{
22-
/* close all open file descriptors except 0-2 */
23-
errno = 0;
24-
25-
long max_fd = sysconf(_SC_OPEN_MAX);
26-
27-
if (max_fd < 0) {
28-
if (errno != 0) {
29-
nsi_print_error_and_exit("%s: %s\n", module, strerror(errno));
30-
} else {
31-
nsi_print_warning("%s: Cannot determine maximum number of file descriptors"
32-
"\n",
33-
module);
34-
}
35-
return max_fd;
36-
}
37-
for (int fd = 3; fd < max_fd; fd++) {
38-
(void)close(fd);
39-
}
40-
return 0;
41-
}
42-
4320
static bool reboot_on_exit;
4421

4522
void native_set_reboot_on_exit(void)
@@ -60,10 +37,6 @@ void maybe_reboot(void)
6037

6138
nsi_get_cmd_line_args(&argc, &argv);
6239

63-
if (close_open_fds() < 0) {
64-
nsi_exit(1);
65-
}
66-
6740
/* Let's set an environment variable which the native_sim hw_info driver may check */
6841
(void)nsi_host_setenv("NATIVE_SIM_RESET_CAUSE", "SOFTWARE", 1);
6942

0 commit comments

Comments
 (0)