/usr/lib/python3/dist-packages/plainbox/vendor/pyglibc/_pipe.py is in python3-plainbox 0.25-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Copyright (c) 2014 Canonical Ltd.
#
# Author: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
:mod:`pyglibc._pipe` -- python wrapper around pipe2
===================================================
This module exposes two functions :func:`pipe()` and :func:`pipe2()`. Both
functions have signatures identical to their counterparts in the standard
library of Python3.4. Both functions work on all supported versions of Python
(that is, 2.7 onwards)
"""
from __future__ import absolute_import
from ctypes import byref
from ctypes import c_int
from plainbox.vendor.glibc import O_CLOEXEC, pipe2 as _pipe2
__author__ = 'Zygmunt Krynicki <zygmunt.krynicki@canonical.com>'
__all__ = ['pipe', 'pipe2']
def pipe():
"""
Wrapper around :func:`pipe2()`` with flags defaulting to ``O_CLOEXEC``.
:returns:
A pair of descriptors (read_end, write_end)
"""
return pipe2(O_CLOEXEC)
def pipe2(flags=0):
"""
Wrapper around ``pipe2(2)``
:param flags:
Optional flags to set. This should almost always include O_CLOEXEC so
that the resulting code is not racy (see the discussion about O_CLOEXEC
to understand why this flag is essential). It can also include
O_NONBLOCK or O_DIRECT, depending on the desired behavior.
:returns:
A pair of descriptors (read_end, write_end)
"""
pair = (c_int * 2)()
_pipe2(byref(pair), flags)
return pair[0], pair[1]
|