diff --git a/nshlib/nsh_script.c b/nshlib/nsh_script.c index 9cf19fd25..b9a210dff 100644 --- a/nshlib/nsh_script.c +++ b/nshlib/nsh_script.c @@ -119,7 +119,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const FAR char *cmd, /* Open the file containing the script */ - vtbl->np.np_fd = open(fullpath, O_RDOK); + vtbl->np.np_fd = open(fullpath, O_RDOK | O_CLOEXEC); if (vtbl->np.np_fd < 0) { if (log) diff --git a/nshlib/nsh_syscmds.c b/nshlib/nsh_syscmds.c index f635a4064..ac14c79ce 100644 --- a/nshlib/nsh_syscmds.c +++ b/nshlib/nsh_syscmds.c @@ -598,7 +598,7 @@ static int cmd_rpmsg_once(FAR struct nsh_vtbl_s *vtbl, return ERROR; } - fd = open(path, 0); + fd = open(path, O_CLOEXEC); if (fd < 0) { nsh_output(vtbl, g_fmtarginvalid, path);