The documentation for fcntl.ioctl() gives the wrong
module for definitions of ioctl operations.
http://www.python.org/doc/lib/module-fcntl.html
ioctl(fd, op, arg)
This function is identical to the fcntl()
function, except that the operations are typically
defined in the library module IOCTL.
As far as I can tell, there is no IOCTL module.
I think what the documentation should say is the
termios module. The termios module defines various
ioctl operation constants.
The following example demonstrates an ioctl operation
to get the current terminal window size.
#!/usr/bin/env python
import termios, fcntl, struct, sys
s = struct.pack("HHHH", 0, 0, 0, 0)
fd_stdout = sys.stdout.fileno()
x = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s)
print '(rows, cols, x pixels, y pixels) =',
print struct.unpack("HHHH", x)
Yours,
Noah
|