Perl 5 version 8.0 documentation
- ioctl FILEHANDLE,FUNCTION,SCALAR
Implements the ioctl(2) function. You'll probably first have to say
- require "ioctl.ph"; # probably in /usr/local/lib/perl/ioctl.ph
to get the correct function definitions. If ioctl.ph doesn't exist or doesn't have the correct definitions you'll have to roll your own, based on your C header files such as <sys/ioctl.h>. (There is a Perl script called h2ph that comes with the Perl kit that may help you in this, but it's nontrivial.) SCALAR will be read and/or written depending on the FUNCTION--a pointer to the string value of SCALAR will be passed as the third argument of the actual
ioctlcall. (If SCALAR has no string value but does have a numeric value, that value will be passed rather than a pointer to the string value. To guarantee this to be true, add a
0to the scalar before using it.) The
unpackfunctions may be needed to manipulate the values of structures used by
- if OS returns: then Perl returns:
- -1 undefined value
- 0 string "0 but true"
- anything else that number
Thus Perl returns true on success and false on failure, yet you can still easily determine the actual value returned by the operating system:
The special string "
0but true" is exempt from -w complaints about improper numeric conversions.
Here's an example of setting a filehandle named
REMOTEto be non-blocking at the system level. You'll have to negotiate
$|on your own, though.