The parameter arg can be one of an integer, absent (treated identically to the integer 0
), an object supporting the read-only buffer interface (most likely a plain Python string) or an object supporting the read-write buffer interface.
In all but the last case, behaviour is as for the fcntl() function.
If a mutable buffer is passed, then the behaviour is determined by the value of the mutate_flag parameter.
If it is false, the buffer's mutability is ignored and behaviour is as for a read-only buffer, except that the 1024 byte limit mentioned above is avoided - so long as the buffer you pass is longer than what the operating system wants to put there, things should work.
If mutate_flag is true, then the buffer is (in effect) passed to the underlying ioctl() system call, the latter's return code is passed back to the calling Python, and the buffer's new contents reflect the action of the ioctl(). This is a slight simplification, because if the supplied buffer is less than 1024 bytes long it is first copied into a static buffer 1024 bytes long which is then passed to ioctl() and copied back into the supplied buffer.
If mutate_flag is not supplied, then in 2.3 it defaults to false. This is planned to change over the next few Python versions: in 2.4 failing to supply mutate_flag will get a warning but the same behavior and in versions later than 2.5 it will default to true.
An example:
>>> import array, fcntl, struct, termios, os >>> os.getpgrp() 13341 >>> struct.unpack('h', fcntl.ioctl(0, termios.TIOCGPGRP, " "))[0] 13341 >>> buf = array.array('h', [0]) >>> fcntl.ioctl(0, termios.TIOCGPGRP, buf, 1) 0 >>> buf array('h', [13341])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4