in fdopen, avoid setting O_APPEND flag if it's already set
this saves a syscall in the case where the underlying open already took place with O_APPEND, which is common because fopen with append modes sets O_APPEND at the time of open before passing the file descriptor to __fdopen.
This commit is contained in:
parent
3af2edee15
commit
758ab35a16
1 changed files with 2 additions and 1 deletions
|
|
@ -32,7 +32,8 @@ FILE *__fdopen(int fd, const char *mode)
|
|||
/* Set append mode on fd if opened for append */
|
||||
if (*mode == 'a') {
|
||||
int flags = __syscall(SYS_fcntl, fd, F_GETFL);
|
||||
__syscall(SYS_fcntl, fd, F_SETFL, flags | O_APPEND);
|
||||
if (!(flags & O_APPEND))
|
||||
__syscall(SYS_fcntl, fd, F_SETFL, flags | O_APPEND);
|
||||
f->flags |= F_APP;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue