summaryrefslogtreecommitdiff
path: root/gzlib.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2012-03-03 10:24:44 -0800
committerMark Adler <madler@alumni.caltech.edu>2012-03-03 10:27:57 -0800
commit755c41dc4bcde575ae654065921206ab4efec962 (patch)
treeae3799ffcd9a6ed0d0206d7dae912ad5fb59fd15 /gzlib.c
parent53bfe01cea647ef6f6b86edbc51d0fad4640e4a6 (diff)
downloadzlib-755c41dc4bcde575ae654065921206ab4efec962.tar.gz
Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen().
Diffstat (limited to 'gzlib.c')
-rw-r--r--gzlib.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/gzlib.c b/gzlib.c
index 7aedab8..fec7fbf 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -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))),