home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

7.2.49 POSIX - Perl Interface to IEEE Std 1003.1

use POSIX;                        # import all symbols
use POSIX qw(setsid);             # import one symbol
use POSIX qw(:errno_h :fcntl_h);  # import sets of symbols

printf "EINTR is %d\n", EINTR;

$sess_id = POSIX::setsid();

$fd = POSIX::open($path, O_CREAT|O_EXCL|O_WRONLY, 0644);
# note: $fd is a filedescriptor, *NOT* a filehandle

The POSIX module permits you to access all (or nearly all) the standard POSIX 1003.1 identifiers. Many of these identifiers have been given Perl-ish interfaces.

This description gives a condensed list of the features available in the POSIX module. Consult your operating system's manpages for general information on most features. Consult the appropriate Perl built-in function whenever a POSIX routine is noted as being identical to the function.

The "Classes" section later in this chapter describes some classes for signal objects, TTY objects, and other miscellaneous objects. The "Functions" section later in this chapter describes POSIX functions from the 1003.1 specification. The remaining sections list various constants and macros in an organization that roughly follows IEEE Std 1003.1b-1993.

WARNING: A few functions are not implemented because they are C-specific.[ 12 ] If you attempt to call one of these functions, it will print a message telling you that it isn't implemented, and will suggest using the Perl equivalent, should one exist. For example, trying to access the setjmp() call will elicit the message: " setjmp() is C-specific: use eval {} instead ".

[12] The 1003.1 standard wisely recommends that other language bindings should avoid duplicating the idiosyncracies of C. This is something we were glad to comply with.

Furthermore, some vendors will claim 1003.1 compliance without passing the POSIX Compliance Test Suites (PCTS). For example, one vendor may not define EDEADLK , or may incorrectly define the semantics of the errno values set by open (2). Perl does not attempt to verify POSIX compliance. That means you can currently say " use POSIX " successfully, and then later in your program find that your vendor has been lax and there's no usable ICANON macro after all. This could be construed to be a bug. Whose bug, we won't venture to guess.

7.2.49.1 Classes

POSIX::SigAction

new

Creates a new POSIX::SigAction object that corresponds to the C struct sigaction . This object will be destroyed automatically when it is no longer needed. The first parameter is the fully qualified name of a subroutine which is a signal handler. The second parameter is a POSIX::SigSet object. The third parameter contains the sa_flags .

$sigset = POSIX::SigSet->new;
$sigaction = POSIX::SigAction->new('main::handler', $sigset,
                 &POSIX::SA_NOCLDSTOP);

This POSIX::SigAction object should be used with the POSIX::sigaction() function.

POSIX::SigSet

new

Creates a new SigSet object. This object will be destroyed automatically when it is no longer needed. Arguments may be supplied to initialize the set. Create an empty set:

$sigset = POSIX::SigSet->new;

Create a set with SIGUSR1 :

$sigset = POSIX::SigSet->new(&POSIX::SIGUSR1);
addset

Adds a signal to a SigSet object. Returns undef on failure.

$sigset->addset(&POSIX::SIGUSR2);
delset

Removes a signal from the SigSet object. Returns undef on failure.

$sigset->delset(&POSIX::SIGUSR2);
emptyset

Initializes the SigSet object to be empty. Returns undef on failure.

$sigset->emptyset();
fillset

Initializes the SigSet object to include all signals. Returns undef on failure.

$sigset->fillset();
ismember

Tests the SigSet object to see whether it contains a specific signal.

if ($sigset->ismember(&POSIX::SIGUSR1 ) ){
    print "contains SIGUSR1\n";
}

POSIX::Termios

new

Creates a new Termios object. This object will be destroyed automatically when it is no longer needed.

$termios = POSIX::Termios->new;
getattr

Gets terminal control attributes for a given fd , 0 by default. Returns undef on failure. Obtain the attributes for standard input:

$termios->getattr()

Obtain the attributes for standard output:

$termios->getattr(1)
getcc

Retrieves a value from the c_cc field of a Termios object. The c_cc field is an array, so an index must be specified.

$c_cc[1] = $termios->getcc(&POSIX::VEOF);
getcflag

Retrieves the c_cflag field of a Termios object.

$c_cflag = $termios->getcflag;
getiflag

Retrieves the c_iflag field of a Termios object.

$c_iflag = $termios->getiflag;
getispeed

Retrieves the input baud rate.

$ispeed = $termios->getispeed;
getlflag

Retrieves the c_lflag field of a Termios object.

$c_lflag = $termios->getlflag;
getoflag

Retrieves the c_oflag field of a Termios object.

$c_oflag = $termios->getoflag;
getospeed

Retrieves the output baud rate.

$ospeed = $termios->getospeed;
setattr

Sets terminal control attributes for a given fd . Returns undef on failure. The following sets attributes immediately for standard output.

$termios->setattr(1, &POSIX::TCSANOW);
setcc

Sets a value in the c_cc field of a Termios object. The c_cc field is an array, so an index must be specified.

$termios->setcc(&POSIX::VEOF, 4);
setcflag

Sets the c_cflag field of a Termios object.

$termios->setcflag(&POSIX::CLOCAL);
setiflag

Sets the c_iflag field of a Termios object.

$termios->setiflag(&POSIX::BRKINT);
setispeed

Sets the input baud rate. Returns undef on failure.

$termios->setispeed(&POSIX::B9600);
setlflag

Sets the c_lflag field of a Termios object.

$termios->setlflag(&POSIX::ECHO);
setoflag

Set the c_oflag field of a Termios object.

$termios->setoflag(&POSIX::OPOST);
setospeed

Sets the output baud rate. Returns undef on failure.

$termios->setospeed(&POSIX::B9600);
Baud rate values

B0 B50 B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 B38400

Terminal interface values

TCSADRAIN TCSANOW TCOON TCIOFLUSH TCOFLUSH TCION TCIFLUSH TCSAFLUSH TCIOFF TCOOFF

c_cc index values

VEOF VEOL VERASE VINTR VKILL VQUIT VSUSP VSTART VSTOP VMIN VTIME NCCS

c_cflag field values

CLOCAL CREAD CSIZE CS5 CS6 CS7 CS8 CSTOPB HUPCL PARENB PARODD

c_iflag field values

BRKINT ICRNL IGNBRK IGNCR IGNPAR INLCR INPCK ISTRIP IXOFF IXON PARMRK

c_lflag field values

ECHO ECHOE ECHOK ECHONL ICANON IEXTEN ISIG NOFLSH TOSTOP

c_oflag field values

OPOST

While these constants are associated with the Termios class, note that they are actually symbols in the POSIX package.

Here's an example of a complete program for getting unbuffered, single-character input on a POSIX system:

#!/usr/bin/perl -w
use strict;
$| = 1;
for (1..4) {
    my $got;
    print "gimme: ";
    $got = getone();
    print "--> $got\n";
}
exit;

BEGIN {
    use POSIX qw(:termios_h);

    my ($term, $oterm, $echo, $noecho, $fd_stdin);

    $fd_stdin = fileno(STDIN);

    $term     = POSIX::Termios->new();
    $term->getattr($fd_stdin);
    $oterm    = $term->getlflag();

    $echo     = ECHO | ECHOK | ICANON;
    $noecho   = $oterm & ~$echo;

    sub cbreak {
        $term->setlflag($noecho);
        $term->setcc(VTIME, 1);
        $term->setattr($fd_stdin, TCSANOW);
    }

    sub cooked {
        $term->setlflag($oterm);
        $term->setcc(VTIME, 0);
        $term->setattr($fd_stdin, TCSANOW);
    }

    sub getone {
        my $key = "";
        cbreak();
        sysread(STDIN, $key, 1);
        cooked();
        return $key;
    }

}

END { cooked() }

7.2.49.2 Functions


Table 7.12: Functions
Function Name Definition
_exit

Identical to the C function _exit (2).

abort

Identical to the C function abort (3).

abs

Identical to Perl's built-in abs function.

access

Determines the accessibility of a file. Returns undef on failure.

if (POSIX::access("/", &POSIX::R_OK ) ){
    print "have read permission\n";
}

acos

Identical to the C function acos (3).

alarm

Identical to Perl's built-in alarm function.

asctime

Identical to the C function asctime (3).

asin

Identical to the C function asin (3).

assert

Similar to the C macro assert (3).

atan

Identical to the C function atan (3).

atan2

Identical to Perl's built-in atan2 function.

atexit

C-specific: use END {} instead.

atof

C-specific.

atoi

C-specific.

atol

C-specific.

bsearch

Not supplied. You should probably be using a hash anyway.

calloc

C-specific.

ceil

Identical to the C function ceil (3).

chdir

Identical to Perl's built-in chdir function.

chmod

Identical to Perl's built-in chmod function.

chown

Identical to Perl's built-in chown function.

clearerr

Use method FileHandle::clearerr() instead.

clock

Identical to the C function clock (3).

close

Closes a file. This uses file descriptors such as those obtained by calling POSIX::open() . Returns undef on failure.

$fd = POSIX::open("foo", &POSIX::O_RDONLY);
POSIX::close($fd);

closedir

Identical to Perl's built-in closedir function.

cos

Identical to Perl's built-in cos function.

cosh

Identical to the C function cosh (3).

creat

Creates a new file. This returns a file descriptor like the ones returned by POSIX::open() . Use POSIX::close() to close the file.

$fd = POSIX::creat("foo", 0611);
POSIX::close($fd);

ctermid

Generates the path name for the controlling terminal.

$path = POSIX::ctermid();

ctime

Identical to the C function ctime (3)

cuserid

Gets the character login name of the user.

$name = POSIX::cuserid();

difftime

Identical to the C function difftime (3).

div

C-specific.

dup

Similar to the C function dup (2). Uses file descriptors such as those obtained by calling POSIX::open() . Returns undef on failure.

dup2

Similar to the C function dup2 (2). Uses file descriptors such as those obtained by calling POSIX::open() . Returns undef on failure.

errno

Returns the value of errno .

$errno = POSIX::errno();

execl

C-specific; use Perl's exec instead.

execle

C-specific; use Perl's exec instead.

execlp

C-specific; use Perl's exec instead.

execv

C-specific; use Perl's exec instead.

execve

C-specific; use Perl's exec instead.

execvp

C-specific; use Perl's exec instead.

exit

Identical to Perl's built-in exit function.

exp

Identical to Perl's built-in exp function.

fabs

Identical to Perl's built-in abs function.

fclose

Use method FileHandle::close() instead.

fcntl

Identical to Perl's built-in fcntl function.

fdopen

Use method FileHandle::new_from_fd() instead.

feof

Use method FileHandle::eof() instead.

ferror

Use method FileHandle::error() instead.

fflush

Use method FileHandle::flush() instead.

fgetc

Use method FileHandle::getc() instead.

fgetpos

Use method FileHandle::getpos() instead.

fgets

Use method FileHandle::gets() instead.

fileno

Use method FileHandle::fileno() instead.

floor

Identical to the C function floor (3).

fmod

Identical to the C function fmod (3).

fopen

Use method FileHandle::open() instead.

fork

Identical to Perl's built-in fork function.

fpathconf

Retrieves the value of a configurable limit on a file or directory. This uses file descriptors such as those obtained by calling POSIX::open() . Returns undef on failure. The following will determine the maximum length of the longest allowable pathname on the filesystem that holds /tmp/foo .

$fd = POSIX::open("/tmp/foo", &POSIX::O_RDONLY);
$path_max = POSIX::fpathconf($fd, &POSIX::_PC_PATH_MAX);

fprintf

C-specific; use Perl's built-in printf function instead.

fputc

C-specific; use Perl's built-in print function instead.

fputs

C-specific; use Perl's built-in print function instead.

fread

C-specific; use Perl's built-in read function instead.

free

C-specific

freopen

C-specific; use Perl's built-in open function instead.

frexp

Returns the mantissa and exponent of a floating-point number.

($mantissa, $exponent) = POSIX::frexp(3.14);

fscanf

C-specific; use <> and regular expressions instead.

fseek

Use method FileHandle::seek() instead.

fsetpos

Use method FileHandle::setpos() instead.

fstat

Gets file status. This uses file descriptors such as those obtained by calling POSIX::open() . The data returned is identical to the data from Perl's built-in stat function. Odd how that happens...

$fd = POSIX::open("foo", &POSIX::O_RDONLY);
@stats = POSIX::fstat($fd);

ftell

Use method FileHandle::tell() instead.

fwrite

C-specific; use Perl's built-in print function instead.

getc

Identical to Perl's built-in getc function.

getchar

Returns one character from STDIN .

getcwd

Returns the name of the current working directory.

getegid

Returns the effective group ID (gid).

getenv

Returns the value of the specified environment variable.

geteuid

Returns the effective user ID (uid).

getgid

Returns the user's real group ID (gid).

getgrgid

Identical to Perl's built-in getgrgid function.

getgrnam

Identical to Perl's built-in getgrnam function.

getgroups

Returns the ids of the user's supplementary groups.

getlogin

Identical to Perl's built-in getlogin function.

getpgrp

Identical to Perl's built-in getpgrp function.

getpid

Returns the process's ID (pid).

getppid

Identical to Perl's built-in getppid function.

getpwnam

Identical to Perl's built-in getpwnam function.

getpwuid

Identical to Perl's built-in getpwuid function.

gets

Returns one line from STDIN .

getuid

Returns the user's ID (uid).

gmtime

Identical to Perl's built-in gmtime function.

isalnum

Identical to the C function, except that it can apply to a single character or to a whole string. (If applied to a whole string, all characters must be of the indicated category.)

isalpha

Identical to the C function, except that it can apply to a single character or to a whole string.

isatty

Returns a Boolean indicating whether the specified filehandle is connected to a TTY.

iscntrl

Identical to the C function, except that it can apply to a single character or to a whole string.

isdigit

Identical to the C function, except that it can apply to a single character or to a whole string.

isgraph

Identical to the C function, except that it can apply to a single character or to a whole string.

islower

Identical to the C function, except that it can apply to a single character or to a whole string.

isprint

Identical to the C function, except that it can apply to a single character or to a whole string.

ispunct

Identical to the C function, except that it can apply to a single character or to a whole string.

isspace

Identical to the C function, except that it can apply to a single character or to a whole string.

isupper

Identical to the C function, except that it can apply to a single character or to a whole string.

isxdigit

Identical to the C function, except that it can apply to a single character or to a whole string.

kill

Identical to Perl's built-in kill function.

labs

C-specific; use Perl's built-in abs function instead.

ldexp

Identical to the C function ldexp (3).

ldiv

C-specific; use the division operator / and Perl's built-in int function instead.

link

Identical to Perl's built-in link function.

localeconv

Gets numeric formatting information. Returns a reference to a hash containing the current locale formatting values. The database for the de (Deutsch or German) locale:

$loc = POSIX::setlocale(&POSIX::LC_ALL, "de");
print "Locale = $loc\n";
$lconv = POSIX::localeconv();
print "decimal_point     = ", $lconv->{decimal_point},     "\n";
print "thousands_sep     = ", $lconv->{thousands_sep},     "\n";
print "grouping          = ", $lconv->{grouping},          "\n";
print "int_curr_symbol   = ", $lconv->{int_curr_symbol},   "\n";
print "currency_symbol   = ", $lconv->{currency_symbol},   "\n";
print "mon_decimal_point = ", $lconv->{mon_decimal_point}, "\n";
print "mon_thousands_sep = ", $lconv->{mon_thousands_sep}, "\n";
print "mon_grouping      = ", $lconv->{mon_grouping},      "\n";
print "positive_sign     = ", $lconv->{positive_sign},     "\n";
print "negative_sign     = ", $lconv->{negative_sign},     "\n";

print "int_frac_digits   = ", $lconv->{int_frac_digits},   "\n";
print "frac_digits       = ", $lconv->{frac_digits},       "\n";
print "p_cs_precedes     = ", $lconv->{p_cs_precedes},     "\n";
print "p_sep_by_space    = ", $lconv->{p_sep_by_space},    "\n";
print "n_cs_precedes     = ", $lconv->{n_cs_precedes},     "\n";
print "n_sep_by_space    = ", $lconv->{n_sep_by_space},    "\n";
print "p_sign_posn       = ", $lconv->{p_sign_posn},       "\n";
print "n_sign_posn       = ", $lconv->{n_sign_posn},       "\n";

localtime

Identical to Perl's built-in localtime function.

log

Identical to Perl's built-in log function.

log10

Identical to the C function log10 (3).

longjmp

C-specific; use Perl's built-in die function instead.

lseek

Moves the read/write file pointer. This uses file descriptors such as those obtained by calling POSIX::open() .

$fd = POSIX::open("foo", &POSIX::O_RDONLY);
$off_t = POSIX::lseek($fd, 0, &POSIX::SEEK_SET);
Returns undef on failure.

malloc

C-specific.

mblen

Identical to the C function mblen (3).

mbstowcs

Identical to the C function mbstowcs (3).

mbtowc

Identical to the C function mbtowc (3).

memchr

C-specific; use Perl's built-in index instead.

memcmp

C-specific; use eq instead.

memcpy

C-specific; use = instead.

memmove

C-specific; use = instead.

memset

C-specific; use x instead.

mkdir

Identical to Perl's built-in mkdir function.

mkfifo

Similar to the C function mkfifo (2). Returns undef on failure.

mktime

Converts date/time information to a calendar time. Returns undef on failure. Synopsis:

mktime(

sec

, 

min

, 

hour

, 

mday

, 

mon

, 

year

, 

wday

 = 0,
                                     

yday

 = 0, 

isdst

 = 0)

The month ( mon ), weekday ( wday ), and yearday ( yday ) begin at zero. That is, January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The year ( year ) is given in years since 1900. That is, the year 1995 is 95; the year 2001 is 101. Consult your system's mktime (3) manpage for details about these and the other arguments. Calendar time for December 12, 1995, at 10:30 am.

$time_t = POSIX::mktime(0, 30, 10, 12, 11, 95);
print "Date = ", POSIX::ctime($time_t);

modf

Returns the integral and fractional parts of a floating-point number.

($fractional, $integral) = POSIX::modf(3.14);

nice

Similar to the C function nice (3). Returns undef on failure.

offsetof

C-specific.

open

Opens a file for reading or writing. This returns file descriptors, not Perl filehandles. Returns undef on failure. Use POSIX::close() to close the file. Open a file read-only:

$fd = POSIX::open("foo");
Open a file for reading and writing:
$fd = POSIX::open("foo", &POSIX::O_RDWR);
Open a file for writing, with truncation:
$fd = POSIX::open("foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC);
Create a new file with mode 0644; set up the file for writing:
$fd = POSIX::open("foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 
        0644);

opendir

Opens a directory for reading. Returns undef on failure.

$dir = POSIX::opendir("/tmp");
@files = POSIX::readdir($dir);
POSIX::closedir($dir);

pathconf

Retrieves the value of a configurable limit on a file or directory. Returns undef on failure. The following will determine the maximum length of the longest allowable pathname on the filesystem that holds /tmp :

$path_max = POSIX::pathconf("/tmp", &POSIX::_PC_PATH_MAX);

pause

Similar to the C function pause (3). Returns undef on failure.

perror

Identical to the C function perror (3).

pipe

Creates an interprocess channel. Returns file descriptors like those returned by POSIX::open() .

($fd0, $fd1) = POSIX::pipe();
POSIX::write($fd0, "hello", 5);
POSIX::read($fd1, $buf, 5);

pow

Computes $x raised to the power $exponent .

$ret = POSIX::pow($x, $exponent);

printf

Prints the specified arguments to STDOUT .

putc

C-specific; use Perl's built-in print function instead.

putchar

C-specific; use Perl's built-in print function instead.

puts

C-specific; use Perl's built-in print function instead.

qsort

C-specific; use Perl's built-in sort function instead.

raise

Sends the specified signal to the current process.

rand

Non-portable; use Perl's built-in rand function instead.

read

Reads from a file. This uses file descriptors such as those obtained by calling POSIX::open() . If the buffer $buf is not large enough for the read, then Perl will extend it to make room for the request. Returns undef on failure.

$fd = POSIX::open("foo", &POSIX::O_RDONLY);
$bytes = POSIX::read($fd, $buf, 3);

readdir

Identical to Perl's built-in readdir function.

realloc

C-specific.

remove

Identical to Perl's built-in unlink function.

rename

Identical to Perl's built-in rename function.

rewind

Seeks to the beginning of the file.

rewinddir

Identical to Perl's built-in rewinddir function.

rmdir

Identical to Perl's built-in rmdir function.

scanf

C-specific; use <> and regular expressions instead.

setgid

Sets the real group id for this process, like assigning to the special variable $( .

setjmp

C-specific; use eval {} instead.

setlocale

Modifies and queries program's locale. The following will set the traditional UNIX system locale behavior.

$loc = POSIX::setlocale(&POSIX::LC_ALL, "C");

setpgid

Similar to the C function setpgid (2). Returns undef on failure.

setsid

Identical to the C function setsid (8).

setuid

Sets the real user ID for this process, like assigning to the special variable $< .

sigaction

Detailed signal management. This uses POSIX::SigAction objects for the $action and $oldaction arguments. Consult your system's sigaction (3) manpage for details. Returns undef on failure.

POSIX::sigaction($sig, $action, $oldaction)

siglongjmp

C-specific; use Perl's built-in die function instead.

sigpending

Examine signals that are blocked and pending. This uses POSIX::SigSet objects for the $sigset argument. Consult your system's sigpending (2) manpage for details. Returns undef on failure.

POSIX::sigpending($sigset)

sigprocmask

Changes and/or examines this process's signal mask. This uses POSIX::SigSet objects for the $sigset and $oldsigset arguments. Consult your system's sigprocmask (2) manpage for details. Returns undef on failure.

POSIX::sigprocmask($how, $sigset, $oldsigset)

sigsetjmp

C-specific; use eval {} instead.

sigsuspend

Install a signal mask and suspend process until signal arrives. This uses POSIX::SigSet objects for the $signal_mask argument. Consult your system's sigsuspend (2) manpage for details. Returns undef on failure.

POSIX::sigsuspend($signal_mask)

sin

Identical to Perl's built-in sin function.

sinh

Identical to the C function sinh (3).

sleep

Identical to Perl's built-in sleep function.

sprintf

Identical to Perl's built-in sprintf function.

sqrt

Identical to Perl's built-in sqrt function.

srand

Identical to Perl's built-in srand function.

sscanf

C-specific; use regular expressions instead.

stat

Identical to Perl's built-in stat function.

strcat

C-specific; use .= instead.

strchr

C-specific; use index instead.

strcmp

C-specific; use eq instead.

strcoll

Identical to the C function strcoll (3).

strcpy

C-specific; use = instead.

strcspn

C-specific; use regular expressions instead.

strerror

Returns the error string for the specified errno .

strftime

Converts date and time information to string. Returns the string.

strftime(

fmt

, 

sec

, 

min

, 

hour

, 

mday

, 

mon

, 

year

, 
            

wday

 = 0, 

yday

 = 0, 

isdst

 = 0)
The month ( mon ), weekday ( wday ), and yearday ( yday ) begin at zero. That is, January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The year ( year ) is given in years since 1900. That is, the year 1995 is 95; the year 2001 is 101. Consult your system's strftime (3) manpage for details about these and the other arguments. The string for Tuesday, December 12, 1995:
$str = POSIX::strftime("%A, %B %d, %Y", 0, 0, 0, 12, 
                        11, 95, 2);
print "$str\n";

strlen

C-specific; use length instead.

strncat

C-specific; use .= and/or substr instead.

strncmp

C-specific; use eq and/or substr instead.

strncpy

C-specific; use = and/or substr instead.

strpbrk

C-specific.

strrchr

C-specific; use rindex and/or substr instead.

strspn

C-specific.

strstr

Identical to Perl's built-in index function.

strtod

C-specific.

strtok

C-specific.

strtol

C-specific.

strtoul

C-specific.

strxfrm

String transformation. Returns the transformed string.

$dst = POSIX::strxfrm($src);

sysconf

Retrieves values of system configurable variables. Returns undef on failure. The following will get the machine's clock speed.

$clock_ticks = POSIX::sysconf(&POSIX::_SC_CLK_TCK);

system

Identical to Perl's built-in system function.

tan

Identical to the C function tan (3).

tanh

Identical to the C function tanh (3).

tcdrain

Similar to the C function tcdrain (3). Returns undef on failure.

tcflow

Similar to the C function tcflow (3). Returns undef on failure.

tcflush

Similar to the C function tcflush (3). Returns undef on failure.

tcgetpgrp

Identical to the C function tcgetpgrp (3).

tcsendbreak

Similar to the C function tcsendbreak (3). Returns undef on failure.

tcsetpgrp

Similar to the C function tcsetpgrp (3). Returns undef on failure.

time

Identical to Perl's built-in time function.

times

Returns elapsed realtime since some point in the past (such as system startup), user and system times for this process, and user and system times for child processes. All times are returned in clock ticks.

($realtime, $user, $system, $cuser, $csystem) = POSIX::times();
Note: Perl's built-in times function returns four values, measured in seconds.

tmpfile

Use method FileHandle::new_tmpfile() instead.

tmpnam

Returns a name for a temporary file.

$tmpfile = POSIX::tmpnam();

tolower

Identical to Perl's built-in lc function.

toupper

Identical to Perl's built-in uc function.

ttyname

Identical to the C function ttyname (3).

tzname

Retrieves the time conversion information from the tzname variable.

POSIX::tzset();
($std, $dst) = POSIX::tzname();

tzset

Identical to the C function tzset (3).

umask

Identical to Perl's built-in umask function.

uname

Gets name of current operating system.

($sysname, $nodename, $release, 
     $version, $machine) = POSIX::uname();

ungetc

Use method FileHandle::ungetc() instead.

unlink

Identical to Perl's built-in unlink function.

utime

Identical to Perl's built-in utime function.

vfprintf

C-specific.

vprintf

C-specific.

vsprintf

C-specific.

wait

Identical to Perl's built-in wait function.

waitpid

Wait for a child process to change state. This is identical to Perl's built-in waitpid function.

$pid = POSIX::waitpid(-1, &POSIX::WNOHANG);
print "status = ", ($? / 256), "\n";

wcstombs

Identical to the C function wcstombs (3).

wctomb

Identical to the C function wctomb (3).

write

Writes to a file. Uses file descriptors such as those obtained by calling POSIX::open() . Returns undef on failure.

$fd = POSIX::open("foo", &POSIX::O_WRONLY);
$buf = "hello";
$bytes = POSIX::write($b, $buf, 5);

7.2.49.3 Pathname constants

_PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON
_PC_MAX_INPUT _PC_NAME_MAX _PC_NO_TRUNC
_PC_PATH_MAX _PC_PIPE_BUF _PC_VDISABLE

7.2.49.4 POSIX constants

_POSIX_ARG_MAX _POSIX_CHILD_MAX _POSIX_CHOWN_RESTRICTED
_POSIX_JOB_CONTROL _POSIX_LINK_MAX _POSIX_MAX_CANON
_POSIX_MAX_INPUT _POSIX_NAME_MAX _POSIX_NGROUPS_MAX
_POSIX_NO_TRUNC _POSIX_OPEN_MAX _POSIX_PATH_MAX
_POSIX_PIPE_BUF _POSIX_SAVED_IDS _POSIX_SSIZE_MAX
_POSIX_STREAM_MAX _POSIX_TZNAME_MAX _POSIX_VDISABLE
_POSIX_VERSION

7.2.49.5 System configuration

_SC_ARG_MAX
_SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL _SC_NGROUPS_MAX
_SC_OPEN_MAX _SC_SAVED_IDS _SC_STREAM_MAX _SC_TZNAME_MAX
_SC_VERSION

7.2.49.6 Error constants

E2BIG
EACCES EAGAIN EBADF EBUSY ECHILD EDEADLK EDOM
EEXIST EFAUL EFBIG EINTR EINVAL EIO EISDIR
EMFILE EMLINK ENAMETOOLONG ENFILE ENODE ENOENT ENOEXEC
ENOLCK ENOMEM ENOSPC ENOSYS ENOTDIR ENOTEMPTY ENOTTY
ENXIO EPERM EPIPE ERANGE EROFS ESPIPE ESRCH
EXDEV

7.2.49.7 File control constants

FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_OK
F_RDLCK F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK
F_WRLCK O_ACCMODE O_APPEND O_CREAT O_EXCL O_NOCTTY
O_NONBLOCK O_RDONLY O_RDWR O_TRUNC O_WRONLY

7.2.49.8 Floating-point constants

DBL_DIG DBL_EPSILON DBL_MANT_DIG
DBL_MAX DBL_MAX_10_EXP DBL_MAX_EXP DBL_MIN
DBL_MIN_10_EXP DBL_MIN_EXP FLT_DIG FLT_EPSILON
FLT_MANT_DIG FLT_MAX FLT_MAX_10_EXP FLT_MAX_EXP
FLT_MIN FLT_MIN_10_EXP FLT_MIN_EXP FLT_RADIX
FLT_ROUNDS LDBL_DIG LDBL_EPSILON LDBL_MANT_DIG
LDBL_MAX LDBL_MAX_10_EXP LDBL_MAX_EXP LDBL_MIN
LDBL_MIN_10_EXP LDBL_MIN_EXP

7.2.49.9 Limit constants

ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX
INT_MAX INT_MIN LINK_MAX LONG_MAX LONG_MIN
MAX_CANON MAX_INPUT MB_LEN_MAX NAME_MAX NGROUPS_MAX
OPEN_MAX PATH_MAX PIPE_BUF SCHAR_MAX SCHAR_MIN
SHRT_MAX SHRT_MIN SSIZE_MAX STREAM_MAX TZNAME_MAX
UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX

7.2.49.10 Locale constants

LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY
LC_NUMERIC LC_TIME

7.2.49.12 Signal constants

SA_NOCLDSTOP SIGABRT SIGALRM
SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT
SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM
SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 SIG_BLOCK
SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK SIG_UNBLOCK

7.2.49.13 Stat constants

S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO
S_IRWXU S_ISGID S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP
S_IXOTH S_IXUSR

7.2.49.14 Stat macros

S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG

7.2.49.15 Stdlib constants

EXIT_FAILURE EXIT_SUCCESS
MB_CUR_MAX RAND_MAX

7.2.49.16 Stdio constants

BUFSIZ EOF FILENAME_MAX
L_ctermid L_cuserid L_tmpname TMP_MAX

7.2.49.17 Time constants

CLK_TCK
CLOCKS_PER_SEC

7.2.49.18 Unistd constants

R_OK SEEK_CUR
SEEK_END SEEK_SET STDIN_FILENO STDOUT_FILENO STRERR_FILENO
W_OK X_OK

7.2.49.19 Wait constants

WNOHANG WUNTRACED

7.2.49.20 Wait macros

WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG


Previous: 7.2.48 overload - Overload Perl's Mathematical Operations Programming Perl Next: 7.2.50 Pod::Text - Convert POD Data to Formatted ASCII Text
7.2.48 overload - Overload Perl's Mathematical Operations Book Index 7.2.50 Pod::Text - Convert POD Data to Formatted ASCII Text







??????????????@Mail.ru