[prev in list] [next in list] [prev in thread] [next in thread]
List: zlib-devel
Subject: [Zlib-devel] Fwd: Re: [PATCH] Use O_CLOEXEC for internal file descriptors
From: arekm () maven ! pl (Arkadiusz =?utf-8?q?Mi=C5=9Bkiewicz?=)
Date: 2012-02-28 9:39:50
Message-ID: 201202281039.50254.arekm () maven ! pl
[Download RAW message or body]
Should zlib support "e" mode just like glibc does?
---------- Forwarded Message ----------
Subject: Re: [PATCH] Use O_CLOEXEC for internal file descriptors
Date: Monday 27 of February 2012
From: Adam Jackson <ajax at redhat.com>
To: Mark Kettenis <mark.kettenis at xs4all.nl>
On Mon, 2012-02-27 at 22:22 +0100, Mark Kettenis wrote:
> That is of course a much better suggestion. And it is possible to use
> the same trick with gzdopen(3) to work around the fact that gzopen()
> doesn't suppert "e", even on Linux systems.
diff -up zlib-1.2.5/gzlib.c.jx zlib-1.2.5/gzlib.c
--- zlib-1.2.5/gzlib.c.jx 2010-04-18 13:53:22.000000000 -0400
+++ zlib-1.2.5/gzlib.c 2012-02-27 16:43:13.991022599 -0500
@@ -90,6 +90,7 @@ local gzFile gz_open(path, fd, mode)
const char *mode;
{
gz_statep state;
+ int want_cloexec = 0;
/* allocate gzFile structure to return */
state = malloc(sizeof(gz_state));
@@ -122,6 +123,9 @@ local gzFile gz_open(path, fd, mode)
case '+': /* can't read and write at the same time */
free(state);
return NULL;
+ case 'e':
+ want_cloexec = 1;
+ break;
case 'b': /* ignore -- will request binary anyway */
break;
case 'f':
@@ -164,6 +168,9 @@ local gzFile gz_open(path, fd, mode)
#ifdef O_BINARY
O_BINARY |
#endif
+#ifdef O_CLOEXEC
+ (want_cloexec ? O_CLOEXEC : 0) |
+#endif
(state->mode == GZ_READ ?
O_RDONLY :
(O_WRONLY | O_CREAT | (
---
There, fixed that for you.
- ajax
-------------------------------------------------------
--
Arkadiusz Mi?kiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic