ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
3.2.37 fcntlfcntl This function calls UNIX's fcntl(2) function. (fcntl stands for "file control".) You'll probably have to say: use Fcntl; first to get the correct function definitions.
The return value of fcntl (and ioctl) is as follows:
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"; fcntl will produce a fatal error if used on a machine
that doesn't implement fcntl(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 lockf(3) function, and
arrange to receive the |