@@ -6547,6 +6547,31 @@ posix_pipe(PyObject *self, PyObject *noargs)
65476547}
65486548#endif /* HAVE_PIPE */
65496549
6550+ #ifdef HAVE_PIPE2
6551+ PyDoc_STRVAR (posix_pipe2__doc__ ,
6552+ "pipe2(flags=0) -> (read_end, write_end)\n\n\
6553+ Create a pipe with flags set atomically.\
6554+ flags is optional and can be constructed by ORing together zero or more\n\
6555+ of these values: O_NONBLOCK, O_CLOEXEC.\n\
6556+ " );
6557+
6558+ static PyObject *
6559+ posix_pipe2 (PyObject * self , PyObject * args )
6560+ {
6561+ int flags = 0 ;
6562+ int fds [2 ];
6563+ int res ;
6564+
6565+ if (!PyArg_ParseTuple (args , "|i:pipe2" , & flags ))
6566+ return NULL ;
6567+
6568+ res = pipe2 (fds , flags );
6569+ if (res != 0 )
6570+ return posix_error ();
6571+ return Py_BuildValue ("(ii)" , fds [0 ], fds [1 ]);
6572+ }
6573+ #endif /* HAVE_PIPE2 */
6574+
65506575#ifdef HAVE_WRITEV
65516576PyDoc_STRVAR (posix_writev__doc__ ,
65526577"writev(fd, buffers) -> byteswritten\n\n\
@@ -9441,6 +9466,9 @@ static PyMethodDef posix_methods[] = {
94419466#ifdef HAVE_PIPE
94429467 {"pipe" , posix_pipe , METH_NOARGS , posix_pipe__doc__ },
94439468#endif
9469+ #ifdef HAVE_PIPE2
9470+ {"pipe2" , posix_pipe2 , METH_VARARGS , posix_pipe2__doc__ },
9471+ #endif
94449472#ifdef HAVE_MKFIFO
94459473 {"mkfifo" , posix_mkfifo , METH_VARARGS , posix_mkfifo__doc__ },
94469474#endif
0 commit comments