libc/stdio: Support 'e'(O_CLOEXEC) in lib_mode2oflags
follow BSD and Linux convention: https://man.openbsd.org/fopen https://www.man7.org/linux/man-pages/man3/fopen.3.html Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
d8aa41de7b
commit
df0e9da1ba
@ -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' :
|
||||
|
Loading…
Reference in New Issue
Block a user