=head1 NAME POSIX - Perl interface to IEEE Std 1003.1 =head1 SYNOPSIS use POSIX (); use POSIX qw(setsid); use POSIX qw(:errno_h :fcntl_h); printf "EINTR is %d\n", EINTR; $sess_id = POSIX::setsid(); $fd = POSIX::open($path, O_CREAT|O_EXCL|O_WRONLY, 0644); # note: that's a filedescriptor, *NOT* a filehandle =head1 DESCRIPTION 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. I with the exception of any POSIX functions with the same name as a built-in Perl function, such as C, C, C, C, etc.., which will be exported only if you ask for them explicitly. This is an unfortunate backwards compatibility feature. You can stop the exporting by saying S> and then use the fully qualified names (I, C), or by giving an explicit import list. If you do neither, and opt for the default, S> has to import I<553 symbols>. This document 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 L for functions which are noted as being identical to Perl's builtin functions. The first section describes POSIX functions from the 1003.1 specification. The second section describes some classes for signal objects, TTY objects, and other miscellaneous objects. The remaining sections list various constants and macros in an organization which roughly follows IEEE Std 1003.1b-1993. =head1 CAVEATS A few functions are not implemented because they are C specific. If you attempt to call these, they will print a message telling you that they aren't implemented, and suggest using the Perl equivalent, should one exist. For example, trying to access the C call will elicit the message "C". Furthermore, some evil vendors will claim 1003.1 compliance, but in fact are not so: they will not pass the PCTS (POSIX Compliance Test Suites). For example, one vendor may not define C, or the semantics of the errno values set by C might not be quite right. Perl does not attempt to verify POSIX compliance. That means you can currently successfully say "use POSIX", and then later in your program you find that your vendor has been lax and there's no usable C macro after all. This could be construed to be a bug. =head1 FUNCTIONS =over 8 =item C<_exit> This is identical to the C function C<_exit()>. It exits the program immediately which means among other things buffered I/O is B flushed. Note that when using threads and in Linux this is B a good way to exit a thread because in Linux processes and threads are kind of the same thing (Note: while this is the situation in early 2003 there are projects under way to have threads with more POSIXly semantics in Linux). If you want not to return from a thread, detach the thread. =item C This is identical to the C function C. It terminates the process with a C signal unless caught by a signal handler or if the handler does not return normally (it e.g. does a C). =item C This is identical to Perl's builtin C function, returning the absolute value of its numerical argument. =item C Determines the accessibility of a file. if( POSIX::access( "/", &POSIX::R_OK ) ){ print "have read permission\n"; } Returns C on failure. Note: do not use C for security purposes. Between the C call and the operation you are preparing for the permissions might change: a classic I. =item C This is identical to the C function C, returning the arcus cosine of its numerical argument. See also L. =item C This is identical to Perl's builtin C function, either for arming or disarming the C timer. =item C This is identical to the C function C. It returns a string of the form "Fri Jun 2 18:22:13 2000\n\0" and it is called thusly $asctime = asctime($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); The C<$mon> is zero-based: January equals C<0>. The C<$year> is 1900-based: 2001 equals C<101>. C<$wday> and C<$yday> default to zero (and are usually ignored anyway), and C<$isdst> defaults to -1. =item C This is identical to the C function C, returning the arcus sine of its numerical argument. See also L. =item C Unimplemented, but you can use L and the L module to achieve similar things. =item C This is identical to the C function C, returning the arcus tangent of its numerical argument. See also L. =item C This is identical to Perl's builtin C function, returning the arcus tangent defined by its two numerical arguments, the I coordinate and the I coordinate. See also L. =item C C is C-specific: use C instead, see L. =item C C is C-specific. Perl converts strings to numbers transparently. If you need to force a scalar to a number, add a zero to it. =item C C is C-specific. Perl converts strings to numbers transparently. If you need to force a scalar to a number, add a zero to it. If you need to have just the integer part, see L. =item C C is C-specific. Perl converts strings to numbers transparently. If you need to force a scalar to a number, add a zero to it. If you need to have just the integer part, see L. =item C C not supplied. For doing binary search on wordlists, see L. =item C C is C-specific. Perl does memory management transparently. =item C This is identical to the C function C, returning the smallest integer value greater than or equal to the given numerical argument. =item C This is identical to Perl's builtin C function, allowing one to change the working (default) directory, see L. =item C This is identical to Perl's builtin C function, allowing one to change file and directory permissions, see L. =item C This is identical to Perl's builtin C function, allowing one to change file and directory owners and groups, see L. =item C Use the method C instead, to reset the error state (if any) and EOF state (if any) of the given stream. =item C This is identical to the C function C, returning the amount of spent processor time in microseconds. =item C Close the file. This uses file descriptors such as those obtained by calling C. $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); POSIX::close( $fd ); Returns C on failure. See also L. =item C This is identical to Perl's builtin C function for closing a directory handle, see L. =item C This is identical to Perl's builtin C function, for returning the cosine of its numerical argument, see L. See also L. =item C This is identical to the C function C, for returning the hyperbolic cosine of its numeric argument. See also L. =item C Create a new file. This returns a file descriptor like the ones returned by C. Use C to close the file. $fd = POSIX::creat( "foo", 0611 ); POSIX::close( $fd ); See also L and its C flag. =item C Generates the path name for the controlling terminal. $path = POSIX::ctermid(); =item C This is identical to the C function C and equivalent to C, see L and L. =item C Get the login name of the owner of the current process. $name = POSIX::cuserid(); =item C This is identical to the C function C, for returning the time difference (in seconds) between two times (as returned by C), see L. =item C
C is C-specific, use L on the usual C division and the modulus C<%>. =item C This is similar to the C function C, for duplicating a file descriptor. This uses file descriptors such as those obtained by calling C. Returns C on failure. =item C This is similar to the C function C, for duplicating a file descriptor to an another known file descriptor. This uses file descriptors such as those obtained by calling C. Returns C on failure. =item C Returns the value of errno. $errno = POSIX::errno(); This identical to the numerical values of the C<$!>, see L. =item C C is C-specific, see L. =item C C is C-specific, see L. =item C C is C-specific, see L. =item C C is C-specific, see L. =item C C is C-specific, see L. =item C C is C-specific, see L. =item C This is identical to Perl's builtin C function for exiting the program, see L. =item C This is identical to Perl's builtin C function for returning the exponent (I-based) of the numerical argument, see L. =item C This is identical to Perl's builtin C function for returning the absolute value of the numerical argument, see L. =item C Use method C instead, or see L. =item C This is identical to Perl's builtin C function, see L. =item C Use method C instead, or see L. =item C Use method C instead, or see L. =item C Use method C instead. =item C Use method C instead. See also C>. =item C Use method C instead, or see L. =item C Use method C instead, or see L. =item C Use method C instead. Similar to EE, also known as L. =item C Use method C instead, or see L. =item C This is identical to the C function C, returning the largest integer value less than or equal to the numerical argument. =item C This is identical to the C function C. $r = fmod($x, $y); It returns the remainder C<$r = $x - $n*$y>, where C<$n = trunc($x/$y)>. The C<$r> has the same sign as C<$x> and magnitude (absolute value) less than the magnitude of C<$y>. =item C Use method C instead, or see L. =item C This is identical to Perl's builtin C function for duplicating the current process, see L and L if you are in Windows. =item C Retrieves the value of a configurable limit on a file or directory. This uses file descriptors such as those obtained by calling C. The following will determine the maximum length of the longest allowable pathname on the filesystem which holds F. $fd = POSIX::open( "/var/foo", &POSIX::O_RDONLY ); $path_max = POSIX::fpathconf($fd, &POSIX::_PC_PATH_MAX); Returns C on failure. =item C C is C-specific, see L instead. =item C C is C-specific, see L instead. =item C C is C-specific, see L instead. =item C C is C-specific, see L instead. =item C C is C-specific. Perl does memory management transparently. =item C C is C-specific, see L instead. =item C Return the mantissa and exponent of a floating-point number. ($mantissa, $exponent) = POSIX::frexp( 1.234e56 ); =item C C is C-specific, use EE and regular expressions instead. =item C Use method C instead, or see L. =item C Use method C instead, or seek L. =item C Get file status. This uses file descriptors such as those obtained by calling C. The data returned is identical to the data from Perl's builtin C function. $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); @stats = POSIX::fstat( $fd ); =item C Use method C instead. =item C Use method C instead, or see L. =item C C is C-specific, see L instead. =item C This is identical to Perl's builtin C function, see L. =item C Returns one character from STDIN. Identical to Perl's C, see L. =item C Returns the name of the current working directory. See also L. =item C Returns the effective group identifier. Similar to Perl' s builtin variable C<$(>, see L. =item C Returns the value of the specified environment variable. The same information is available through the C<%ENV> array. =item C Returns the effective user identifier. Identical to Perl's builtin C<$E> variable, see L. =item C Returns the user's real group identifier. Similar to Perl's builtin variable C<$)>, see L. =item C This is identical to Perl's builtin C function for returning group entries by group identifiers, see L. =item C This is identical to Perl's builtin C function for returning group entries by group names, see L. =item C Returns the ids of the user's supplementary groups. Similar to Perl's builtin variable C<$)>, see L. =item C This is identical to Perl's builtin C function for returning the user name associated with the current session, see L. =item C This is identical to Perl's builtin C function for returning the process group identifier of the current process, see L. =item C Returns the process identifier. Identical to Perl's builtin variable C<$$>, see L. =item C This is identical to Perl's builtin C function for returning the process identifier of the parent process of the current process , see L. =item C This is identical to Perl's builtin C function for returning user entries by user names, see L. =item C This is identical to Perl's builtin C function for returning user entries by user identifiers, see L. =item C Returns one line from C, similar to EE, also known as the C function, see L. B: if you have C programs that still use C, be very afraid. The C function is a source of endless grief because it has no buffer overrun checks. It should B be used. The C function should be preferred instead. =item C Returns the user's identifier. Identical to Perl's builtin C<$E> variable, see L. =item C This is identical to Perl's builtin C function for converting seconds since the epoch to a date in Greenwich Mean Time, see L. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. You may want to use the C\wE|perlrecharclass/Word characters>> construct instead. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. =item C Returns a boolean indicating whether the specified filehandle is connected to a tty. Similar to the C<-t> operator, see L. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. You may want to use the C\dE|perlrecharclass/Digits>> construct instead. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. Do B use C unless you don't care about the current locale. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. You may want to use the C\sE|perlrecharclass/Whitespace>> construct instead. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. Do B use C unless you don't care about the current locale. =item C Deprecated function whose use raises a warning, and which is slated to be removed in a future Perl version. It is very similar to matching against S>, which you should convert to use instead. The function is deprecated because 1) it doesn't handle UTF-8 encoded strings properly; and 2) it returns C even if the input is the empty string. The function return is always based on the current locale, whereas using locale rules is optional with the regular expression, based on pragmas in effect and pattern modifiers (see L and L). The function returns C if the input string is empty, or if the corresponding C function returns C for every byte in the string. =item C This is identical to Perl's builtin C function for sending signals to processes (often to terminate them), see L. =item C (For returning absolute values of long integers.) C is C-specific, see L instead. =item C This is identical to the C function, except the order of arguments is consistent with Perl's builtin C with the added restriction of only one path, not an list of paths. Does the same thing as the C function but changes the owner of a symbolic link instead of the file the symbolic link points to. =item C This is identical to the C function C for multiplying floating point numbers with powers of two. $x_quadrupled = POSIX::ldexp($x, 2); =item C (For computing dividends of long integers.) C is C-specific, use C and C instead. =item C This is identical to Perl's builtin C function for creating hard links into files, see L. =item C Get numeric formatting information. Returns a reference to a hash containing the current locale formatting values. Users of this function should also read L, which provides a comprehensive discussion of Perl locale handling, including L. Here is how to query the database for the B (Deutsch or German) locale. my $loc = POSIX::setlocale( &POSIX::LC_ALL, "de" ); print "Locale: \"$loc\"\n"; my $lconv = POSIX::localeconv(); foreach my $property (qw( decimal_point thousands_sep grouping int_curr_symbol currency_symbol mon_decimal_point mon_thousands_sep mon_grouping positive_sign negative_sign int_frac_digits frac_digits p_cs_precedes p_sep_by_space n_cs_precedes n_sep_by_space p_sign_posn n_sign_posn )) { printf qq(%s: "%s",\n), $property, $lconv->{$property}; } =item C This is identical to Perl's builtin C function for converting seconds since the epoch to a date see L. =item C This is identical to Perl's builtin C function, returning the natural (I-based) logarithm of the numerical argument, see L. =item C This is identical to the C function C, returning the 10-base logarithm of the numerical argument. You can also use sub log10 { log($_[0]) / log(10) } or sub log10 { log($_[0]) / 2.30258509299405 } or sub log10 { log($_[0]) * 0.434294481903252 } =item C C is C-specific: use L instead. =item C Move the file's read/write position. This uses file descriptors such as those obtained by calling C. $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); $off_t = POSIX::lseek( $fd, 0, &POSIX::SEEK_SET ); Returns C on failure. =item C C is C-specific. Perl does memory management transparently. =item C This is identical to the C function C. Perl does not have any support for the wide and multibyte characters of the C standards, so this might be a rather useless function. =item C This is identical to the C function C. Perl does not have any support for the wide and multibyte characters of the C standards, so this might be a rather useless function. =item C This is identical to the C function C. Perl does not have any support for the wide and multibyte characters of the C standards, so this might be a rather useless function. =item C C is C-specific, see L instead. =item C C is C-specific, use C instead, see L. =item C C is C-specific, use C<=>, see L, or see L. =item C C is C-specific, use C<=>, see L, or see L. =item C C is C-specific, use C instead, see L. =item C This is identical to Perl's builtin C function for creating directories, see L. =item C This is similar to the C function C for creating FIFO special files. if (mkfifo($path, $mode)) { .... Returns C on failure. The C<$mode> is similar to the mode of C, see L, though for C you B specify the C<$mode>. =item C Convert date/time info to a calendar time. Synopsis: mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = -1) The month (C), weekday (C), and yearday (C) begin at zero. I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The year (C) is given in years since 1900. I.e. The year 1995 is 95; the year 2001 is 101. Consult your system's C 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); Returns C on failure. =item C Return the integral and fractional parts of a floating-point number. ($fractional, $integral) = POSIX::modf( 3.14 ); =item C This is similar to the C function C, for changing the scheduling preference of the current process. Positive arguments mean more polite process, negative values more needy process. Normal user processes can only be more polite. Returns C on failure. =item C C is C-specific, you probably want to see L instead. =item C Open a file for reading for writing. This returns file descriptors, not Perl filehandles. Use C to close the file. Open a file read-only with mode 0666. $fd = POSIX::open( "foo" ); Open a file for read and write. $fd = POSIX::open( "foo", &POSIX::O_RDWR ); Open a file for write, with truncation. $fd = POSIX::open( "foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC ); Create a new file with mode 0640. Set up the file for writing. $fd = POSIX::open( "foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0640 ); Returns C on failure. See also L. =item C Open a directory for reading. $dir = POSIX::opendir( "/var" ); @files = POSIX::readdir( $dir ); POSIX::closedir( $dir ); Returns C on failure. =item C Retrieves the value of a configurable limit on a file or directory. The following will determine the maximum length of the longest allowable pathname on the filesystem which holds C. $path_max = POSIX::pathconf( "/var", &POSIX::_PC_PATH_MAX ); Returns C on failure. =item C This is similar to the C function C, which suspends the execution of the current process until a signal is received. Returns C on failure. =item C This is identical to the C function C, which outputs to the standard error stream the specified message followed by C<": "> and the current error string. Use the C function and the C<$!> variable instead, see L and L. =item C Create an interprocess channel. This returns file descriptors like those returned by C. my ($read, $write) = POSIX::pipe(); POSIX::write( $write, "hello", 5 ); POSIX::read( $read, $buf, 5 ); See also L. =item C Computes C<$x> raised to the power C<$exponent>. $ret = POSIX::pow( $x, $exponent ); You can also use the C<**> operator, see L. =item C Formats and prints the specified arguments to STDOUT. See also L. =item C C is C-specific, see L instead. =item C C is C-specific, see L instead. =item C C is C-specific, see L instead. =item C C is C-specific, see L instead. =item C Sends the specified signal to the current process. See also L and the C<$$> in L. =item C C is non-portable, see L instead. =item C Read from a file. This uses file descriptors such as those obtained by calling C. If the buffer C<$buf> is not large enough for the read then Perl will extend it to make room for the request. $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); $bytes = POSIX::read( $fd, $buf, 3 ); Returns C on failure. See also L. =item C This is identical to Perl's builtin C function for reading directory entries, see L. =item C C is C-specific. Perl does memory management transparently. =item C This is identical to Perl's builtin C function for removing files, see L. =item C This is identical to Perl's builtin C function for renaming files, see L. =item C Seeks to the beginning of the file. =item C This is identical to Perl's builtin C function for rewinding directory entry streams, see L. =item C This is identical to Perl's builtin C function for removing (empty) directories, see L. =item C C is C-specific, use EE and regular expressions instead, see L. =item C Sets the real group identifier and the effective group identifier for this process. Similar to assigning a value to the Perl's builtin C<$)> variable, see L, except that the latter will change only the real user identifier, and that the setgid() uses only a single numeric argument, as opposed to a space-separated list of numbers. =item C C is C-specific: use C instead, see L. =item C Modifies and queries the program's underlying locale. Users of this function should read L, whch provides a comprehensive discussion of Perl locale handling, knowledge of which is necessary to properly use this function. It contains L. The discussion here is merely a summary reference for C. Note that Perl itself is almost entirely unaffected by the locale except within the scope of S>. (Exceptions are listed in L.) The following examples assume use POSIX qw(setlocale LC_ALL LC_CTYPE); has been issued. The following will set the traditional UNIX system locale behavior (the second argument C<"C">). $loc = setlocale( LC_ALL, "C" ); The following will query the current C category. (No second argument means 'query'.) $loc = setlocale( LC_CTYPE ); The following will set the C behaviour according to the locale environment variables (the second argument C<"">). Please see your system's C documentation for the locale environment variables' meaning or consult L. $loc = setlocale( LC_CTYPE, "" ); The following will set the C behaviour to Argentinian Spanish. B: The naming and availability of locales depends on your operating system. Please consult L for how to find out which locales are available in your system. $loc = setlocale( LC_COLLATE, "es_AR.ISO8859-1" ); =item C This is similar to the C function C for setting the process group identifier of the current process. Returns C on failure. =item C This is identical to the C function C for setting the session identifier of the current process. =item C Sets the real user identifier and the effective user identifier for this process. Similar to assigning a value to the Perl's builtin C<$E> variable, see L, except that the latter will change only the real user identifier. =item C Detailed signal management. This uses C objects for the C and C arguments (the oldaction can also be just a hash reference). Consult your system's C manpage for details, see also C. Synopsis: sigaction(signal, action, oldaction = 0) Returns C on failure. The C must be a number (like C), not a string (like C<"SIGHUP">), though Perl does try hard to understand you. If you use the C flag, the signal handler will in addition to the first argument, the signal name, also receive a second argument, a hash reference, inside which are the following keys with the following semantics, as defined by POSIX/SUSv3: signo the signal number errno the error number code if this is zero or less, the signal was sent by a user process and the uid and pid make sense, otherwise the signal was sent by the kernel The following are also defined by POSIX/SUSv3, but unfortunately not very widely implemented: pid the process id generating the signal uid the uid of the process id generating the signal status exit value or signal for SIGCHLD band band event for SIGPOLL A third argument is also passed to the handler, which contains a copy of the raw binary contents of the C structure: if a system has some non-POSIX fields, this third argument is where to C them from. Note that not all C values make sense simultaneously (some are valid only for certain signals, for example), and not all values make sense from Perl perspective, you should to consult your system's C and possibly also C documentation. =item C C is C-specific: use L instead. =item C Examine signals that are blocked and pending. This uses C objects for the C argument. Consult your system's C manpage for details. Synopsis: sigpending(sigset) Returns C on failure. =item C Change and/or examine calling process's signal mask. This uses C objects for the C and C arguments. Consult your system's C manpage for details. Synopsis: sigprocmask(how, sigset, oldsigset = 0) Returns C on failure. Note that you can't reliably block or unblock a signal from its own signal handler if you're using safe signals. Other signals can be blocked or unblocked reliably. =item C C is C-specific: use C instead, see L. =item C Install a signal mask and suspend process until signal arrives. This uses C objects for the C argument. Consult your system's C manpage for details. Synopsis: sigsuspend(signal_mask) Returns C on failure. =item C This is identical to Perl's builtin C function for returning the sine of the numerical argument, see L. See also L. =item C This is identical to the C function C for returning the hyperbolic sine of the numerical argument. See also L. =item C This is functionally identical to Perl's builtin C function for suspending the execution of the current for process for certain number of seconds, see L. There is one significant difference, however: C returns the number of B seconds, while the C returns the number of slept seconds. =item C This is similar to Perl's builtin C function for returning a string that has the arguments formatted as requested, see L. =item C This is identical to Perl's builtin C function. for returning the square root of the numerical argument, see L. =item C Give a seed the pseudorandom number generator, see L. =item C C is C-specific, use regular expressions instead, see L. =item C This is identical to Perl's builtin C function for returning information about files and directories. =item C C is C-specific, use C<.=> instead, see L. =item C C is C-specific, see L instead. =item C C is C-specific, use C or C instead, see L. =item C This is identical to the C function C for collating (comparing) strings transformed using the C function. Not really needed since Perl can do this transparently, see L. =item C C is C-specific, use C<=> instead, see L. =item C C is C-specific, use regular expressions instead, see L. =item C Returns the error string for the specified errno. Identical to the string form of the C<$!>, see L. =item C Convert date and time information to string. Returns the string. Synopsis: strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) The month (C), weekday (C), and yearday (C) begin at zero. I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The year (C) is given in years since 1900. I.e., the year 1995 is 95; the year 2001 is 101. Consult your system's C manpage for details about these and the other arguments. If you want your code to be portable, your format (C) argument should use only the conversion specifiers defined by the ANSI C standard (C89, to play safe). These are C. But even then, the B of some of the conversion specifiers are non-portable. For example, the specifiers C change according to the locale settings of the user, and both how to set locales (the locale names) and what output to expect are non-standard. The specifier C changes according to the timezone settings of the user and the timezone computation rules of the operating system. The C specifier is notoriously unportable since the names of timezones are non-standard. Sticking to the numeric specifiers is the safest route. The given arguments are made consistent as though by calling C before calling your system's C function, except that the C value is not affected. The string for Tuesday, December 12, 1995. $str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 ); print "$str\n"; =item C C is C-specific, use C instead, see L. =item C C is C-specific, use C<.=> instead, see L. =item C C is C-specific, use C instead, see L. =item C C is C-specific, use C<=> instead, see L. =item C C is C-specific, use regular expressions instead, see L. =item C C is C-specific, see L instead. =item C C is C-specific, use regular expressions instead, see L. =item C This is identical to Perl's builtin C function, see L. =item C String to double translation. Returns the parsed number and the number of characters in the unparsed portion of the string. Truly POSIX-compliant systems set C<$!> (C<$ERRNO>) to indicate a translation error, so clear C<$!> before calling strtod. However, non-POSIX systems may not check for overflow, and therefore will never set C<$!>. strtod respects any POSIX I C settings, regardless of whether or not it is called from Perl code that is within the scope of S>. To parse a string C<$str> as a floating point number use $! = 0; ($num, $n_unparsed) = POSIX::strtod($str); The second returned item and C<$!> can be used to check for valid input: if (($str eq '') || ($n_unparsed != 0) || $!) { die "Non-numeric input $str" . ($! ? ": $!\n" : "\n"); } When called in a scalar context strtod returns the parsed number. =item C C is C-specific, use regular expressions instead, see L, or L. =item C String to (long) integer translation. Returns the parsed number and the number of characters in the unparsed portion of the string. Truly POSIX-compliant systems set C<$!> (C<$ERRNO>) to indicate a translation error, so clear C<$!> before calling C. However, non-POSIX systems may not check for overflow, and therefore will never set C<$!>. C should respect any POSIX I settings. To parse a string C<$str> as a number in some base C<$base> use $! = 0; ($num, $n_unparsed) = POSIX::strtol($str, $base); The base should be zero or between 2 and 36, inclusive. When the base is zero or omitted strtol will use the string itself to determine the base: a leading "0x" or "0X" means hexadecimal; a leading "0" means octal; any other leading characters mean decimal. Thus, "1234" is parsed as a decimal number, "01234" as an octal number, and "0x1234" as a hexadecimal number. The second returned item and C<$!> can be used to check for valid input: if (($str eq '') || ($n_unparsed != 0) || !$!) { die "Non-numeric input $str" . $! ? ": $!\n" : "\n"; } When called in a scalar context strtol returns the parsed number. =item C String to unsigned (long) integer translation. C is identical to C except that C only parses unsigned integers. See L for details. Note: Some vendors supply C and C but not C. Other vendors that do supply C parse "-1" as a valid value. =item C String transformation. Returns the transformed string. $dst = POSIX::strxfrm( $src ); Used in conjunction with the C function, see L. Not really needed since Perl can do this transparently, see L. =item C Retrieves values of system configurable variables. The following will get the machine's clock speed. $clock_ticks = POSIX::sysconf( &POSIX::_SC_CLK_TCK ); Returns C on failure. =item C This is identical to Perl's builtin C function, see L. =item C This is identical to the C function C, returning the tangent of the numerical argument. See also L. =item C This is identical to the C function C, returning the hyperbolic tangent of the numerical argument. See also L. =item C This is similar to the C function C for draining the output queue of its argument stream. Returns C on failure. =item C This is similar to the C function C for controlling the flow of its argument stream. Returns C on failure. =item C This is similar to the C function C for flushing the I/O buffers of its argument stream. Returns C on failure. =item C This is identical to the C function C for returning the process group identifier of the foreground process group of the controlling terminal. =item C This is similar to the C function C for sending a break on its argument stream. Returns C on failure. =item C This is similar to the C function C for setting the process group identifier of the foreground process group of the controlling terminal. Returns C on failure. =item C