aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gzlib.c12
-rw-r--r--zlib.h5
2 files changed, 15 insertions, 2 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)
94 const char *mode; 94 const char *mode;
95{ 95{
96 gz_statep state; 96 gz_statep state;
97 int cloexec = 0, exclusive = 0;
97 98
98 /* check input */ 99 /* check input */
99 if (path == NULL) 100 if (path == NULL)
@@ -133,6 +134,12 @@ local gzFile gz_open(path, fd, mode)
133 return NULL; 134 return NULL;
134 case 'b': /* ignore -- will request binary anyway */ 135 case 'b': /* ignore -- will request binary anyway */
135 break; 136 break;
137 case 'e':
138 cloexec = 1;
139 break;
140 case 'x':
141 exclusive = 1;
142 break;
136 case 'f': 143 case 'f':
137 state->strategy = Z_FILTERED; 144 state->strategy = Z_FILTERED;
138 break; 145 break;
@@ -184,9 +191,12 @@ local gzFile gz_open(path, fd, mode)
184#ifdef O_BINARY 191#ifdef O_BINARY
185 O_BINARY | 192 O_BINARY |
186#endif 193#endif
194#ifdef O_CLOEXEC
195 (cloexec ? O_CLOEXEC : 0) |
196#endif
187 (state->mode == GZ_READ ? 197 (state->mode == GZ_READ ?
188 O_RDONLY : 198 O_RDONLY :
189 (O_WRONLY | O_CREAT | ( 199 (O_WRONLY | O_CREAT | (exclusive ? O_EXCL : 0) | (
190 state->mode == GZ_WRITE ? 200 state->mode == GZ_WRITE ?
191 O_TRUNC : 201 O_TRUNC :
192 O_APPEND))), 202 O_APPEND))),
diff --git a/zlib.h b/zlib.h
index 2cbd981..ca6123c 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1217,7 +1217,10 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
1217 1217
1218 "a" can be used instead of "w" to request that the gzip stream that will 1218 "a" can be used instead of "w" to request that the gzip stream that will
1219 be written be appended to the file. "+" will result in an error, since 1219 be written be appended to the file. "+" will result in an error, since
1220 reading and writing to the same gzip file is not supported. 1220 reading and writing to the same gzip file is not supported. The addition of
1221 "x" when writing will create the file exclusively, which fails if the file
1222 already exists. On systems that support it, the addition of "e" when
1223 reading or writing will set the flag to close the file on an execve() call.
1221 1224
1222 These functions, as well as gzip, will read and decode a sequence of gzip 1225 These functions, as well as gzip, will read and decode a sequence of gzip
1223 streams in a file. The append function of gzopen() can be used to create 1226 streams in a file. The append function of gzopen() can be used to create