aboutsummaryrefslogtreecommitdiff
path: root/gzlib.c
diff options
context:
space:
mode:
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)
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))),