Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

News / Blogs

- Perl Buzz
- Perl Iron Man
- Perlsphere
- Planet Perl
- TPF news
- Use Perl

See also

- CPAN
- Perl.org
- Perl.com
- Perl 5 Wiki
- Perl Jobs
- Perl Mongers
- Perl Monks

Contact

- Site designed and maintained by Jon Allen (JJ)
- http://perl.jonallen.info

- View the project page and FAQs

# ioctl

Perl 5 version 10.1 documentation
Go to top

# ioctl

Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage

- 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. If sys/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 `ioctl` 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 a `0` to the scalar before using it.) The `pack` and `unpack` functions may be needed to manipulate the values of structures used by `ioctl`.

  The return value of `ioctl` (and `fcntl`) 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.

Recently read

Tools

- Preferences