mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Issue #12196: Add pipe2() to the os module.
This commit is contained in:
parent
04a90b4611
commit
daafdd5bea
7 changed files with 71 additions and 13 deletions
|
@ -6547,6 +6547,31 @@ posix_pipe(PyObject *self, PyObject *noargs)
|
|||
}
|
||||
#endif /* HAVE_PIPE */
|
||||
|
||||
#ifdef HAVE_PIPE2
|
||||
PyDoc_STRVAR(posix_pipe2__doc__,
|
||||
"pipe2(flags=0) -> (read_end, write_end)\n\n\
|
||||
Create a pipe with flags set atomically.\
|
||||
flags is optional and can be constructed by ORing together zero or more\n\
|
||||
of these values: O_NONBLOCK, O_CLOEXEC.\n\
|
||||
");
|
||||
|
||||
static PyObject *
|
||||
posix_pipe2(PyObject *self, PyObject *args)
|
||||
{
|
||||
int flags = 0;
|
||||
int fds[2];
|
||||
int res;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|i:pipe2", &flags))
|
||||
return NULL;
|
||||
|
||||
res = pipe2(fds, flags);
|
||||
if (res != 0)
|
||||
return posix_error();
|
||||
return Py_BuildValue("(ii)", fds[0], fds[1]);
|
||||
}
|
||||
#endif /* HAVE_PIPE2 */
|
||||
|
||||
#ifdef HAVE_WRITEV
|
||||
PyDoc_STRVAR(posix_writev__doc__,
|
||||
"writev(fd, buffers) -> byteswritten\n\n\
|
||||
|
@ -9441,6 +9466,9 @@ static PyMethodDef posix_methods[] = {
|
|||
#ifdef HAVE_PIPE
|
||||
{"pipe", posix_pipe, METH_NOARGS, posix_pipe__doc__},
|
||||
#endif
|
||||
#ifdef HAVE_PIPE2
|
||||
{"pipe2", posix_pipe2, METH_VARARGS, posix_pipe2__doc__},
|
||||
#endif
|
||||
#ifdef HAVE_MKFIFO
|
||||
{"mkfifo", posix_mkfifo, METH_VARARGS, posix_mkfifo__doc__},
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue