diff options
| author | Rich Felker <dalias@aerifal.cx> | 2014-02-07 01:16:53 -0500 | 
|---|---|---|
| committer | Rich Felker <dalias@aerifal.cx> | 2014-02-07 01:16:53 -0500 | 
| commit | 758ab35a167ac17a4e3102cee5d16b75053842a7 (patch) | |
| tree | f6e052426088b5c7a894a9d3a1213ffa1847f766 /src | |
| parent | 3af2edee150484940916eba1984f78c3b965dd05 (diff) | |
| download | musl-758ab35a167ac17a4e3102cee5d16b75053842a7.tar.gz | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/stdio/__fdopen.c | 3 | 
1 files changed, 2 insertions, 1 deletions
| diff --git a/src/stdio/__fdopen.c b/src/stdio/__fdopen.c index a2ca62b1..a6ae73a2 100644 --- a/src/stdio/__fdopen.c +++ b/src/stdio/__fdopen.c @@ -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;  	} | 
