first to get the correct function definitions.
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 = fcntl(...) or $retval = -1; printf "System returned %d\n", $retval;
Here, even the string "
For example, since Perl always sets the close-on-exec flag for file descriptors above 2, if you wanted to pass file descriptor 3 to a subprocess, you might want to clear the flag like this:
use Fcntl; open TTY,"+>/dev/tty" or die "Can't open /dev/tty: $!\n"; fileno TTY == 3 or die "Internal error: fd mixup"; fcntl TTY, &F_SETFL, 0 or die "Can't clear the close-on-exec flag: $!\n";
will produce a fatal error if used on a machine
that doesn't implement
(2). On machines that do implement
it, you can do such things as modify the close-on-exec flags, modify
the non-blocking I/O flags, emulate the
(3) function, and
arrange to receive the