This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[patch/cygwin] O_CLOEXEC/F_DUPFD_CLOEXEC/dup3/pipe2
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: newlib at sourceware dot org
- Date: Thu, 14 Jan 2010 19:49:18 +0100
- Subject: [patch/cygwin] O_CLOEXEC/F_DUPFD_CLOEXEC/dup3/pipe2
- Reply-to: newlib at sourceware dot org
Hi,
I applied the below patch for Cygwin only. I just created a matching
patch to Cygwin which adds this Linux-specific functionality.
Corinna
* libc/include/sys/_default_fcntl.h (O_CLOEXEC): Define as _FNOINHERIT.
(F_DUPFD_CLOEXEC): Define for Cygwin.
* libc/include/sys/unistd.h (dup3): Define for Cygwin.
(pipe2): Ditto.
Index: libc/include/sys/_default_fcntl.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/_default_fcntl.h,v
retrieving revision 1.4
diff -u -p -r1.4 _default_fcntl.h
--- libc/include/sys/_default_fcntl.h 8 Dec 2009 13:50:41 -0000 1.4
+++ libc/include/sys/_default_fcntl.h 14 Jan 2010 18:48:36 -0000
@@ -51,6 +51,8 @@ extern "C" {
#define O_BINARY _FBINARY
#define O_TEXT _FTEXT
#define O_NOINHERIT _FNOINHERIT
+/* O_CLOEXEC is the Linux equivalent to O_NOINHERIT */
+#define O_CLOEXEC _FNOINHERIT
/* The windows header files define versions with a leading underscore. */
#define _O_RDONLY O_RDONLY
@@ -122,6 +124,9 @@ extern "C" {
#define F_CNVT 12 /* Convert a fhandle to an open fd */
#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
#endif /* !_POSIX_SOURCE */
+#ifdef __CYGWIN__
+#define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */
+#endif
/* fcntl(2) flags (l_type field of flock structure) */
#define F_RDLCK 1 /* read lock */
Index: libc/include/sys/unistd.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/unistd.h,v
retrieving revision 1.75
diff -u -p -r1.75 unistd.h
--- libc/include/sys/unistd.h 22 Dec 2009 13:07:24 -0000 1.75
+++ libc/include/sys/unistd.h 14 Jan 2010 18:48:36 -0000
@@ -38,6 +38,7 @@ int _EXFUN(daemon, (int nochdir, int noc
int _EXFUN(dup, (int __fildes ));
int _EXFUN(dup2, (int __fildes, int __fildes2 ));
#if defined(__CYGWIN__)
+int _EXFUN(dup3, (int __fildes, int __fildes2, int flags));
int _EXFUN(eaccess, (const char *__path, int __mode));
void _EXFUN(endusershell, (void));
int _EXFUN(euidaccess, (const char *__path, int __mode));
@@ -129,6 +130,9 @@ int _EXFUN(pause, (void ));
int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
#endif
int _EXFUN(pipe, (int __fildes[2] ));
+#ifdef __CYGWIN__
+int _EXFUN(pipe2, (int __fildes[2], int flags));
+#endif
ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat