rest25/library/fcntl.rst => rest262/library/fcntl.rst
44   If the :cfunc:`fcntl` fails, an :exc:`IOError` is raised.
45
46
47.. function:: ioctl(fd, op[, arg[, mutate_flag]])
48
49   This function is identical to the :func:`fcntl` function, except that the
50   operations are typically defined in the library module :mod:`termios` and the
51   argument handling is even more complicated.
n52+ 
53+   The op parameter is limited to values that can fit in 32-bits.
52
53   The parameter *arg* can be one of an integer, absent (treated identically to the
54   integer ``0``), an object supporting the read-only buffer interface (most likely
55   a plain Python string) or an object supporting the read-write buffer interface.
56
57   In all but the last case, behaviour is as for the :func:`fcntl` function.
58
59   If a mutable buffer is passed, then the behaviour is determined by the value of
99
100
101.. function:: lockf(fd, operation, [length, [start, [whence]]])
102
103   This is essentially a wrapper around the :func:`fcntl` locking calls.  *fd* is
104   the file descriptor of the file to lock or unlock, and *operation* is one of the
105   following values:
106
n107-* :const:`LOCK_UN` -- unlock
n109+   * :const:`LOCK_UN` -- unlock
110+   * :const:`LOCK_SH` -- acquire a shared lock
111+   * :const:`LOCK_EX` -- acquire an exclusive lock
108
n109-* :const:`LOCK_SH` -- acquire a shared lock
110- 
111-* :const:`LOCK_EX` -- acquire an exclusive lock
112- 
113-   When *operation* is :const:`LOCK_SH` or :const:`LOCK_EX`, it can also be bit-
113+   When *operation* is :const:`LOCK_SH` or :const:`LOCK_EX`, it can also be
114-   wise OR'd with :const:`LOCK_NB` to avoid blocking on lock acquisition.  If
114+   bitwise ORed with :const:`LOCK_NB` to avoid blocking on lock acquisition.
115-   :const:`LOCK_NB` is used and the lock cannot be acquired, an :exc:`IOError` will
115+   If :const:`LOCK_NB` is used and the lock cannot be acquired, an
116-   be raised and the exception will have an *errno* attribute set to
116+   :exc:`IOError` will be raised and the exception will have an *errno*
117-   :const:`EACCES` or :const:`EAGAIN` (depending on the operating system; for
117+   attribute set to :const:`EACCES` or :const:`EAGAIN` (depending on the
118-   portability, check for both values).  On at least some systems, :const:`LOCK_EX`
118+   operating system; for portability, check for both values).  On at least some
119-   can only be used if the file descriptor refers to a file opened for writing.
119+   systems, :const:`LOCK_EX` can only be used if the file descriptor refers to a
120+   file opened for writing.
120
121   *length* is the number of bytes to lock, *start* is the byte offset at which the
122   lock starts, relative to *whence*, and *whence* is as with :func:`fileobj.seek`,
123   specifically:
124
n125-* :const:`0` -- relative to the start of the file (:const:`SEEK_SET`)
n126+   * :const:`0` -- relative to the start of the file (:const:`SEEK_SET`)
126- 
127-* :const:`1` -- relative to the current buffer position (:const:`SEEK_CUR`)
127+   * :const:`1` -- relative to the current buffer position (:const:`SEEK_CUR`)
128- 
129-* :const:`2` -- relative to the end of the file (:const:`SEEK_END`)
128+   * :const:`2` -- relative to the end of the file (:const:`SEEK_END`)
130
131   The default for *start* is 0, which means to start at the beginning of the file.
132   The default for *length* is 0 which means to lock to the end of the file.  The
133   default for *whence* is also 0.
134
135Examples (all on a SVR4 compliant system)::
136
137   import struct, fcntl, os
146integer value; in the second example it will hold a string value.  The structure
147lay-out for the *lockdata* variable is system dependent --- therefore using the
148:func:`flock` call may be better.
149
150
151.. seealso::
152
153   Module :mod:`os`
t154-      If the locking flags :const:`O_SHLOCK` and :const:`O_EXLOCK` are present in the
t153+      If the locking flags :const:`O_SHLOCK` and :const:`O_EXLOCK` are present
155-      :mod:`os` module, the :func:`os.open` function provides a more platform-
154+      in the :mod:`os` module, the :func:`os.open` function provides a more
156-      independent alternative to the :func:`lockf` and :func:`flock` functions.
155+      platform-independent alternative to the :func:`lockf` and :func:`flock`
156+      functions.
157
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op