Bug report : fcntlmodule.so (fonction ioctl) python 1.5.2
Guido van Rossum
guido at cnri.reston.va.us
Fri Sep 24 15:01:48 EDT 1999
IMPORTANT NOTE: please report all bugs via the Python Bugs List on the
web: http://www.python.org/search/search_bugs.html. This lets you
search to find out whether the bug was already reported (and if so, if
there was a fix); it also requests important information like platform
and Python version.
David Berthelot <berthelo at lirmm.fr> writes:
> i think, i found a bug (and a fix).
>
> In the "fcntlmodule.so", the "ioctl" function does not work with
> an optional int parameter but currently it works only with an
> optional string parameter.
>
> So i think that the line number 76 of fcntlmodule.c :
> 76: ret = ioctl(fd, code, arg);
>
> should be replaced by:
> 76: ret = ioctl(fd, code, &arg);
>
> I think it does it, doesn't it ?
> Yes, unlike fcntl, ioctl uses a pointer for its 3rd arg.
Which ioctl command were you using? Whether arg must be an int or a
pointer to an int or a pointer to something else depends on which
command you are issuing.
If you need a pointer to an int, I recommend using the struct module
to convert it to a string. E.g. (untested) something like:
import struct, fcntl
def ioctl_p_int(fd, request, value):
s = struct.pack("i", value)
s2 = fcntl.ioctl(fd, request, s)
(ret,) = struct.unpack("i", s2) # this always returns a tuple
return ret
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-list
mailing list