Changeset 391 for python/trunk/Doc/library/fcntl.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/fcntl.rst
r2 r391 1 2 :mod:`fcntl` --- The :func:`fcntl` and :func:`ioctl` system calls 3 ================================================================= 1 :mod:`fcntl` --- The ``fcntl`` and ``ioctl`` system calls 2 ========================================================= 4 3 5 4 .. module:: fcntl … … 10 9 11 10 .. index:: 12 pair: UNIX @Unix; file control13 pair: UNIX @Unix; I/O control11 pair: UNIX; file control 12 pair: UNIX; I/O control 14 13 15 14 This module performs file control and I/O control on file descriptors. It is an 16 interface to the :c func:`fcntl` and :cfunc:`ioctl` Unix routines.15 interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines. 17 16 18 17 All functions in this module take a file descriptor *fd* as their first 19 18 argument. This can be an integer file descriptor, such as returned by 20 19 ``sys.stdin.fileno()``, or a file object, such as ``sys.stdin`` itself, which 21 provides a :meth:` fileno` which returns a genuine file descriptor.20 provides a :meth:`~io.IOBase.fileno` which returns a genuine file descriptor. 22 21 23 22 The module defines the following functions: … … 27 26 28 27 Perform the requested operation on file descriptor *fd* (file objects providing 29 a :meth:`fileno` method are accepted as well). The operation is defined by *op* 28 a :meth:`~io.IOBase.fileno` method are accepted as well). The operation is 29 defined by *op* 30 30 and is operating system dependent. These codes are also found in the 31 31 :mod:`fcntl` module. The argument *arg* is optional, and defaults to the integer 32 32 value ``0``. When present, it can either be an integer value, or a string. 33 33 With the argument missing or an integer value, the return value of this function 34 is the integer return value of the C :c func:`fcntl` call. When the argument is34 is the integer return value of the C :c:func:`fcntl` call. When the argument is 35 35 a string it represents a binary structure, e.g. created by :func:`struct.pack`. 36 36 The binary data is copied to a buffer whose address is passed to the C 37 :c func:`fcntl` call. The return value after a successful call is the contents37 :c:func:`fcntl` call. The return value after a successful call is the contents 38 38 of the buffer, converted to a string object. The length of the returned string 39 39 will be the same as the length of the *arg* argument. This is limited to 1024 … … 42 42 violation or a more subtle data corruption. 43 43 44 If the :c func:`fcntl` fails, an :exc:`IOError` is raised.44 If the :c:func:`fcntl` fails, an :exc:`IOError` is raised. 45 45 46 46 47 47 .. function:: ioctl(fd, op[, arg[, mutate_flag]]) 48 48 49 This function is identical to the :func:` fcntl` function, except that the49 This function is identical to the :func:`~fcntl.fcntl` function, except that the 50 50 operations are typically defined in the library module :mod:`termios` and the 51 51 argument handling is even more complicated. … … 57 57 a plain Python string) or an object supporting the read-write buffer interface. 58 58 59 In all but the last case, behaviour is as for the :func:`fcntl` function. 59 In all but the last case, behaviour is as for the :func:`~fcntl.fcntl` 60 function. 60 61 61 62 If a mutable buffer is passed, then the behaviour is determined by the value of … … 96 97 97 98 Perform the lock operation *op* on file descriptor *fd* (file objects providing 98 a :meth:` fileno` method are accepted as well). See the Unix manual99 a :meth:`~io.IOBase.fileno` method are accepted as well). See the Unix manual 99 100 :manpage:`flock(2)` for details. (On some systems, this function is emulated 100 using :c func:`fcntl`.)101 using :c:func:`fcntl`.) 101 102 102 103 103 104 .. function:: lockf(fd, operation, [length, [start, [whence]]]) 104 105 105 This is essentially a wrapper around the :func:` fcntl` locking calls. *fd* is106 the file descriptor of the file to lock or unlock, and *operation* is one of the107 following values:106 This is essentially a wrapper around the :func:`~fcntl.fcntl` locking calls. 107 *fd* is the file descriptor of the file to lock or unlock, and *operation* 108 is one of the following values: 108 109 109 110 * :const:`LOCK_UN` -- unlock … … 120 121 file opened for writing. 121 122 122 *length* is the number of bytes to lock, *start* is the byte offset at which the123 lock starts, relative to *whence*, and *whence* is as with :func:`fileobj.seek`,124 specifically:123 *length* is the number of bytes to lock, *start* is the byte offset at 124 which the lock starts, relative to *whence*, and *whence* is as with 125 :func:`io.IOBase.seek`, specifically: 125 126 126 * :const:`0` -- relative to the start of the file (: const:`SEEK_SET`)127 * :const:`1` -- relative to the current buffer position (: const:`SEEK_CUR`)128 * :const:`2` -- relative to the end of the file (: const:`SEEK_END`)127 * :const:`0` -- relative to the start of the file (:data:`os.SEEK_SET`) 128 * :const:`1` -- relative to the current buffer position (:data:`os.SEEK_CUR`) 129 * :const:`2` -- relative to the end of the file (:data:`os.SEEK_END`) 129 130 130 131 The default for *start* is 0, which means to start at the beginning of the file. … … 151 152 152 153 Module :mod:`os` 153 If the locking flags :const:`O_SHLOCK` and :const:`O_EXLOCK` are present 154 in the :mod:`os` module (on BSD only), the :func:`os.open` function 155 provides an alternative to the :func:`lockf` and :func:`flock` functions. 154 If the locking flags :data:`~os.O_SHLOCK` and :data:`~os.O_EXLOCK` are 155 present in the :mod:`os` module (on BSD only), the :func:`os.open` 156 function provides an alternative to the :func:`lockf` and :func:`flock` 157 functions. 156 158
Note:
See TracChangeset
for help on using the changeset viewer.