diff --git a/libs/libc/stdio/lib_fopen.c b/libs/libc/stdio/lib_fopen.c index 9798654735..537a92abca 100644 --- a/libs/libc/stdio/lib_fopen.c +++ b/libs/libc/stdio/lib_fopen.c @@ -49,7 +49,7 @@ #define MODE_NONE 0 /* No access mode determined */ #define MODE_MASK (MODE_R | MODE_W | MODE_A) -#define FLAG_KEEP (O_BINARY | O_EXCL) +#define FLAG_KEEP (O_BINARY | O_CLOEXEC | O_EXCL) /**************************************************************************** * Public Functions @@ -263,6 +263,21 @@ int lib_mode2oflags(FAR const char *mode) } break; + /* Open for close on execute */ + + case 'e' : + if ((state & MODE_MASK) != MODE_NONE) + { + /* The file will be closed on execute */ + + oflags |= O_CLOEXEC; + } + else + { + goto errout; + } + break; + /* Open for exclusive access ("{r|w|a|b|+}x") */ case 'x' :