diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2012-03-03 10:24:44 -0800 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2012-03-03 10:27:57 -0800 |
commit | 755c41dc4bcde575ae654065921206ab4efec962 (patch) | |
tree | ae3799ffcd9a6ed0d0206d7dae912ad5fb59fd15 /gzlib.c | |
parent | 53bfe01cea647ef6f6b86edbc51d0fad4640e4a6 (diff) | |
download | zlib-755c41dc4bcde575ae654065921206ab4efec962.tar.gz |
Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen().
Diffstat (limited to 'gzlib.c')
-rw-r--r-- | gzlib.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -94,6 +94,7 @@ local gzFile gz_open(path, fd, mode) const char *mode; { gz_statep state; + int cloexec = 0, exclusive = 0; /* check input */ if (path == NULL) @@ -133,6 +134,12 @@ local gzFile gz_open(path, fd, mode) return NULL; case 'b': /* ignore -- will request binary anyway */ break; + case 'e': + cloexec = 1; + break; + case 'x': + exclusive = 1; + break; case 'f': state->strategy = Z_FILTERED; break; @@ -184,9 +191,12 @@ local gzFile gz_open(path, fd, mode) #ifdef O_BINARY O_BINARY | #endif +#ifdef O_CLOEXEC + (cloexec ? O_CLOEXEC : 0) | +#endif (state->mode == GZ_READ ? O_RDONLY : - (O_WRONLY | O_CREAT | ( + (O_WRONLY | O_CREAT | (exclusive ? O_EXCL : 0) | ( state->mode == GZ_WRITE ? O_TRUNC : O_APPEND))), |