[issue1471] ioctl doesn't work properly on 64-bit OpenBSD

Nicholas Marriott report at bugs.python.org
Tue Nov 20 10:25:19 CET 2007


Nicholas Marriott added the comment:

I can also reproduce this on OpenBSD/amd64 and was one of the people who
discussed it with the submitter before he created this report.

> So what's the definition of struct winsize on these systems?

The definition of struct winsize on both 32-bit and 64-bit OpenBSD
platforms is:

struct winsize {
        unsigned short  ws_row;         /* rows, in characters */
        unsigned short  ws_col;         /* columns, in characters */
        unsigned short  ws_xpixel;      /* horizontal size, pixels */
        unsigned short  ws_ypixel;      /* vertical size, pixels */
};

We have verified that (sizeof (struct winsize)) is 8 on all three
platforms (32-bit i386, and 64-bit amd64 and sparc64).

> Also, why do you think this is a bug in Python? AFAICT, the specific 
> ioctl call does not occur in Python, but in your own code.

This Python code fails:

fcntl.ioctl(fd, termios.TIOCSWINSZ, struct.pack("HHHH",80,25,0,0))

(Error: IOError: [Errno 25] Inappropriate ioctl for device) This code
also fails with the same error message (I would expect EINVAL instead):

fcntl.ioctl(0, termios.TIOCSWINSZ, "")

Corresponding test C code to call the ioctl (as listed in a previous
message) works without problems on all three platforms. I don't know how
Python fcntl.ioctl works and perhaps the problem is not Python, but I am
having to try fairly hard to think what else could be involved.

The constant appears to be the correct ioctl number. (Python code:

python2.5 -c 'import termios; print "%d" % (termios.TIOCSWINSZ)'

matches C code:

#include <termios.h>
int main(void) { printf("%ld\n", TIOCSWINSZ); }

on all three platforms.)

I am told it works on Linux. However, Linux declares ioctl as:

int ioctl(int d, int request, ...); 

So 'request' is 32-bits, but on OpenBSD ioctl is declared as:

int ioctl(int d, unsigned long request, ...);

So on amd64 and sparc64, 'request' is 64-bits. Could this be a factor?

-- Nicholas.

----------
nosy: +nicm

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1471>
__________________________________


More information about the Python-bugs-list mailing list