Movatterモバイル変換


[0]ホーム

URL:


functions /ioctl
(source,CPAN)
You are viewing the version of this documentation from Perl 5.16.1.View the latest version
#ioctl FILEHANDLE,FUNCTION,SCALAR

Implements the ioctl(2) function. You'll probably first have to say

require "sys/ioctl.ph";  # probably in $Config{archlib}/sys/ioctl.ph

to get the correct function definitions. Ifsys/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 calledh2ph 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 C pointer to the string value of SCALAR will be passed as the third argument of the actualioctl call. (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 a0 to the scalar before using it.) Thepack andunpack functions may be needed to manipulate the values of structures used byioctl.

The return value ofioctl (andfcntl) is as follows:

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:

$retval = ioctl(...) || -1;printf "System returned %d\n", $retval;

The special string"0 but true" is exempt from-w complaints about improper numeric conversions.

Portability issues:"ioctl" in perlport.

Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.

The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.


[8]ページ先頭

©2009-2025 Movatter.jp