1=head1 NAME 2 3POSIX - Perl interface to IEEE Std 1003.1 4 5=head1 SYNOPSIS 6 7 use POSIX (); 8 use POSIX qw(setsid); 9 use POSIX qw(:errno_h :fcntl_h); 10 11 printf "EINTR is %d\n", EINTR; 12 13 $sess_id = POSIX::setsid(); 14 15 $fd = POSIX::open($path, O_CREAT|O_EXCL|O_WRONLY, 0644); 16 # note: that's a filedescriptor, *NOT* a filehandle 17 18=head1 DESCRIPTION 19 20The POSIX module permits you to access all (or nearly all) the standard 21POSIX 1003.1 identifiers. Many of these identifiers have been given Perl-ish 22interfaces. 23 24This document gives a condensed list of the features available in the POSIX 25module. Consult your operating system's manpages for general information on 26most features. Consult L<perlfunc> for functions which are noted as being 27identical or almost identical to Perl's builtin functions. 28 29The first section describes POSIX functions from the 1003.1 specification. 30The second section describes some classes for signal objects, TTY objects, 31and other miscellaneous objects. The remaining sections list various 32constants and macros in an organization which roughly follows IEEE Std 331003.1b-1993. 34 35=head1 CAVEATS 36 37I<Everything is exported by default> (with a handful of exceptions). 38This is an unfortunate backwards compatibility feature and its use is 39B<strongly L<discouraged|perlpolicy/discouraged>>. 40You should either prevent the exporting (by saying S<C<use POSIX ();>>, 41as usual) and then use fully qualified names (e.g. C<POSIX::SEEK_END>), 42or give an explicit import list. 43If you do neither and opt for the default (as in S<C<use POSIX;>>), you 44will import I<hundreds and hundreds> of symbols into your namespace. 45 46A few functions are not implemented because they are C specific. If you 47attempt to call these, they will print a message telling you that they 48aren't implemented, and suggest using the Perl equivalent, should one 49exist. For example, trying to access the C<setjmp()> call will elicit the 50message "C<setjmp() is C-specific: use eval {} instead>". 51 52Furthermore, some evil vendors will claim 1003.1 compliance, but in fact 53are not so: they will not pass the PCTS (POSIX Compliance Test Suites). 54For example, one vendor may not define C<EDEADLK>, or the semantics of the 55errno values set by C<open(2)> might not be quite right. Perl does not 56attempt to verify POSIX compliance. That means you can currently 57successfully say "use POSIX", and then later in your program you find 58that your vendor has been lax and there's no usable C<ICANON> macro after 59all. This could be construed to be a bug. 60 61=head1 FUNCTIONS 62 63=over 8 64 65=item C<_exit> 66 67This is identical to the C function C<_exit()>. It exits the program 68immediately which means among other things buffered I/O is B<not> flushed. 69 70Note that when using threads and in Linux this is B<not> a good way to 71exit a thread because in Linux processes and threads are kind of the 72same thing (Note: while this is the situation in early 2003 there are 73projects under way to have threads with more POSIXly semantics in Linux). 74If you want not to return from a thread, detach the thread. 75 76=item C<abort> 77 78This is identical to the C function C<abort()>. It terminates the 79process with a C<SIGABRT> signal unless caught by a signal handler or 80if the handler does not return normally (it e.g. does a C<longjmp>). 81 82=item C<abs> 83 84This is identical to Perl's builtin C<abs()> function, returning the absolute 85value of its numerical argument (except that C<POSIX::abs()> must be provided 86an explicit value (rather than relying on an implicit C<$_>): 87 88 $absolute_value = POSIX::abs(42); # good 89 90 $absolute_value = POSIX::abs(); # throws exception 91 92=item C<access> 93 94Determines the accessibility of a file. 95 96 if( POSIX::access( "/", &POSIX::R_OK ) ){ 97 print "have read permission\n"; 98 } 99 100Returns C<undef> on failure. Note: do not use C<access()> for 101security purposes. Between the C<access()> call and the operation 102you are preparing for the permissions might change: a classic 103I<race condition>. 104 105=item C<acos> 106 107This is identical to the C function C<acos()>, returning 108the arcus cosine of its numerical argument. See also L<Math::Trig>. 109 110=item C<acosh> 111 112This is identical to the C function C<acosh()>, returning the 113hyperbolic arcus cosine of its numerical argument [C99]. See also 114L<Math::Trig>. 115 116=item C<alarm> 117 118This is identical to Perl's builtin C<alarm()> function, either for arming or 119disarming the C<SIGARLM> timer, except that C<POSIX::alarm()> must be provided 120an explicit value (rather than relying on an implicit C<$_>): 121 122 POSIX::alarm(3) # good 123 124 POSIX::alarm() # throws exception 125 126=item C<asctime> 127 128This is identical to the C function C<asctime()>. It returns 129a string of the form 130 131 "Fri Jun 2 18:22:13 2000\n\0" 132 133and it is called thusly 134 135 $asctime = asctime($sec, $min, $hour, $mday, $mon, 136 $year, $wday, $yday, $isdst); 137 138The C<$mon> is zero-based: January equals C<0>. The C<$year> is 1391900-based: 2001 equals C<101>. C<$wday> and C<$yday> default to zero 140(and are usually ignored anyway), and C<$isdst> defaults to -1. 141 142=item C<asin> 143 144This is identical to the C function C<asin()>, returning 145the arcus sine of its numerical argument. See also L<Math::Trig>. 146 147=item C<asinh> 148 149This is identical to the C function C<asinh()>, returning the 150hyperbolic arcus sine of its numerical argument [C99]. See also 151L<Math::Trig>. 152 153=item C<assert> 154 155Unimplemented, but you can use L<perlfunc/die> and the L<Carp> module 156to achieve similar things. 157 158=item C<atan> 159 160This is identical to the C function C<atan()>, returning the 161arcus tangent of its numerical argument. See also L<Math::Trig>. 162 163=item C<atanh> 164 165This is identical to the C function C<atanh()>, returning the 166hyperbolic arcus tangent of its numerical argument [C99]. See also 167L<Math::Trig>. 168 169=item C<atan2> 170 171This is identical to Perl's builtin C<atan2()> function, returning 172the arcus tangent defined by its two numerical arguments, the I<y> 173coordinate and the I<x> coordinate. See also L<Math::Trig>. 174 175=item C<atexit> 176 177Not implemented. C<atexit()> is C-specific: use C<END {}> instead, see L<perlmod>. 178 179=item C<atof> 180 181Not implemented. C<atof()> is C-specific. Perl converts strings to numbers transparently. 182If you need to force a scalar to a number, add a zero to it. 183 184=item C<atoi> 185 186Not implemented. C<atoi()> is C-specific. Perl converts strings to numbers transparently. 187If you need to force a scalar to a number, add a zero to it. 188If you need to have just the integer part, see L<perlfunc/int>. 189 190=item C<atol> 191 192Not implemented. C<atol()> is C-specific. Perl converts strings to numbers transparently. 193If you need to force a scalar to a number, add a zero to it. 194If you need to have just the integer part, see L<perlfunc/int>. 195 196=item C<bsearch> 197 198C<bsearch()> not supplied. For doing binary search on wordlists, 199see L<Search::Dict>. 200 201=item C<calloc> 202 203Not implemented. C<calloc()> is C-specific. Perl does memory management transparently. 204 205=item C<cbrt> 206 207The cube root [C99]. 208 209=item C<ceil> 210 211This is identical to the C function C<ceil()>, returning the smallest 212integer value greater than or equal to the given numerical argument. 213 214=item C<chdir> 215 216This is identical to Perl's builtin C<chdir()> function, allowing one to 217change the working (default) directory -- see L<perlfunc/chdir> -- with the 218exception that C<POSIX::chdir()> must be provided an explicit value (rather 219than relying on an implicit C<$_>): 220 221 $rv = POSIX::chdir('path/to/dir'); # good 222 223 $rv = POSIX::chdir(); # throws exception 224 225=item C<chmod> 226 227This is identical to Perl's builtin C<chmod()> function, allowing 228one to change file and directory permissions -- see L<perlfunc/chmod> -- with 229the exception that C<POSIX::chmod()> can only change one file at a time 230(rather than a list of files): 231 232 $c = chmod 0664, $file1, $file2; # good 233 234 $c = POSIX::chmod 0664, $file1; # throws exception 235 236 $c = POSIX::chmod 0664, $file1, $file2; # throws exception 237 238=item C<chown> 239 240This is identical to Perl's builtin C<chown()> function, allowing one 241to change file and directory owners and groups, see L<perlfunc/chown>. 242 243=item C<clearerr> 244 245Not implemented. Use the method C<IO::Handle::clearerr()> instead, to reset the error 246state (if any) and EOF state (if any) of the given stream. 247 248=item C<clock> 249 250This is identical to the C function C<clock()>, returning the 251amount of spent processor time in microseconds. 252 253=item C<close> 254 255Close the file. This uses file descriptors such as those obtained by calling 256C<POSIX::open>. 257 258 $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); 259 POSIX::close( $fd ); 260 261Returns C<undef> on failure. 262 263See also L<perlfunc/close>. 264 265=item C<closedir> 266 267This is identical to Perl's builtin C<closedir()> function for closing 268a directory handle, see L<perlfunc/closedir>. 269 270=item C<cos> 271 272This is identical to Perl's builtin C<cos()> function, for returning 273the cosine of its numerical argument, see L<perlfunc/cos>. 274See also L<Math::Trig>. 275 276=item C<cosh> 277 278This is identical to the C function C<cosh()>, for returning 279the hyperbolic cosine of its numeric argument. See also L<Math::Trig>. 280 281=item C<copysign> 282 283Returns C<x> but with the sign of C<y> [C99]. 284 285 $x_with_sign_of_y = POSIX::copysign($x, $y); 286 287See also L</signbit>. 288 289=item C<creat> 290 291Create a new file. This returns a file descriptor like the ones returned by 292C<POSIX::open>. Use C<POSIX::close> to close the file. 293 294 $fd = POSIX::creat( "foo", 0611 ); 295 POSIX::close( $fd ); 296 297See also L<perlfunc/sysopen> and its C<O_CREAT> flag. 298 299=item C<ctermid> 300 301Generates the path name for the controlling terminal. 302 303 $path = POSIX::ctermid(); 304 305=item C<ctime> 306 307This is identical to the C function C<ctime()> and equivalent 308to C<asctime(localtime(...))>, see L</asctime> and L</localtime>. 309 310=item C<cuserid> 311 312Get the login name of the owner of the current process. 313 314 $name = POSIX::cuserid(); 315 316=item C<difftime> 317 318This is identical to the C function C<difftime()>, for returning 319the time difference (in seconds) between two times (as returned 320by C<time()>), see L</time>. 321 322=item C<div> 323 324Not implemented. C<div()> is C-specific, use L<perlfunc/int> on the usual C</> division and 325the modulus C<%>. 326 327=item C<dup> 328 329This is similar to the C function C<dup()>, for duplicating a file 330descriptor. 331 332This uses file descriptors such as those obtained by calling 333C<POSIX::open>. 334 335Returns C<undef> on failure. 336 337=item C<dup2> 338 339This is similar to the C function C<dup2()>, for duplicating a file 340descriptor to an another known file descriptor. 341 342This uses file descriptors such as those obtained by calling 343C<POSIX::open>. 344 345Returns C<undef> on failure. 346 347=item C<erf> 348 349The error function [C99]. 350 351=item C<erfc> 352 353The complementary error function [C99]. 354 355=item C<errno> 356 357Returns the value of errno. 358 359 $errno = POSIX::errno(); 360 361This identical to the numerical values of the C<$!>, see L<perlvar/$ERRNO>. 362 363=item C<execl> 364 365Not implemented. C<execl()> is C-specific, see L<perlfunc/exec>. 366 367=item C<execle> 368 369Not implemented. C<execle()> is C-specific, see L<perlfunc/exec>. 370 371=item C<execlp> 372 373Not implemented. C<execlp()> is C-specific, see L<perlfunc/exec>. 374 375=item C<execv> 376 377Not implemented. C<execv()> is C-specific, see L<perlfunc/exec>. 378 379=item C<execve> 380 381Not implemented. C<execve()> is C-specific, see L<perlfunc/exec>. 382 383=item C<execvp> 384 385Not implemented. C<execvp()> is C-specific, see L<perlfunc/exec>. 386 387=item C<exit> 388 389This is identical to Perl's builtin C<exit()> function for exiting the 390program, see L<perlfunc/exit>. 391 392=item C<exp> 393 394This is identical to Perl's builtin C<exp()> function for 395returning the exponent (I<e>-based) of the numerical argument, 396see L<perlfunc/exp>. 397 398=item C<expm1> 399 400Equivalent to C<exp(x) - 1>, but more precise for small argument values [C99]. 401 402See also L</log1p>. 403 404=item C<fabs> 405 406This is identical to Perl's builtin C<abs()> function for returning 407the absolute value of the numerical argument, see L<perlfunc/abs>. 408 409=item C<fclose> 410 411Not implemented. Use method C<IO::Handle::close()> instead, or see L<perlfunc/close>. 412 413=item C<fcntl> 414 415This is identical to Perl's builtin C<fcntl()> function, 416see L<perlfunc/fcntl>. 417 418=item C<fdopen> 419 420Not implemented. Use method C<IO::Handle::new_from_fd()> instead, or see L<perlfunc/open>. 421 422=item C<feof> 423 424Not implemented. Use method C<IO::Handle::eof()> instead, or see L<perlfunc/eof>. 425 426=item C<ferror> 427 428Not implemented. Use method C<IO::Handle::error()> instead. 429 430=item C<fflush> 431 432Not implemented. Use method C<IO::Handle::flush()> instead. 433See also C<L<perlvar/$OUTPUT_AUTOFLUSH>>. 434 435=item C<fgetc> 436 437Not implemented. Use method C<IO::Handle::getc()> instead, or see L<perlfunc/read>. 438 439=item C<fgetpos> 440 441Not implemented. Use method C<IO::Seekable::getpos()> instead, or see L<perlfunc/seek>. 442 443=item C<fgets> 444 445Not implemented. Use method C<IO::Handle::gets()> instead. Similar to E<lt>E<gt>, also known 446as L<perlfunc/readline>. 447 448=item C<fileno> 449 450Not implemented. Use method C<IO::Handle::fileno()> instead, or see L<perlfunc/fileno>. 451 452=item C<floor> 453 454This is identical to the C function C<floor()>, returning the largest 455integer value less than or equal to the numerical argument. 456 457=item C<fdim> 458 459"Positive difference", S<C<x - y>> if S<C<x E<gt> y>>, zero otherwise [C99]. 460 461=item C<fegetround> 462 463Returns the current floating point rounding mode, one of 464 465 FE_TONEAREST FE_TOWARDZERO FE_UPWARD FE_UPWARD 466 467C<FE_TONEAREST> is like L</round>, C<FE_TOWARDZERO> is like L</trunc> [C99]. 468 469=item C<fesetround> 470 471Sets the floating point rounding mode, see L</fegetround> [C99]. 472 473=item C<fma> 474 475"Fused multiply-add", S<C<x * y + z>>, possibly faster (and less lossy) 476than the explicit two operations [C99]. 477 478 my $fused = POSIX::fma($x, $y, $z); 479 480=item C<fmax> 481 482Maximum of C<x> and C<y>, except when either is C<NaN>, returns the other [C99]. 483 484 my $min = POSIX::fmax($x, $y); 485 486=item C<fmin> 487 488Minimum of C<x> and C<y>, except when either is C<NaN>, returns the other [C99]. 489 490 my $min = POSIX::fmin($x, $y); 491 492=item C<fmod> 493 494This is identical to the C function C<fmod()>. 495 496 $r = fmod($x, $y); 497 498It returns the remainder S<C<$r = $x - $n*$y>>, where S<C<$n = trunc($x/$y)>>. 499The C<$r> has the same sign as C<$x> and magnitude (absolute value) 500less than the magnitude of C<$y>. 501 502=item C<fopen> 503 504Not implemented. Use method C<IO::File::open()> instead, or see L<perlfunc/open>. 505 506=item C<fork> 507 508This is identical to Perl's builtin C<fork()> function 509for duplicating the current process, see L<perlfunc/fork> 510and L<perlfork> if you are in Windows. 511 512=item C<fpathconf> 513 514Retrieves the value of a configurable limit on a file or directory. This 515uses file descriptors such as those obtained by calling C<POSIX::open>. 516 517The following will determine the maximum length of the longest allowable 518pathname on the filesystem which holds F</var/foo>. 519 520 $fd = POSIX::open( "/var/foo", &POSIX::O_RDONLY ); 521 $path_max = POSIX::fpathconf($fd, &POSIX::_PC_PATH_MAX); 522 523Returns C<undef> on failure. 524 525=item C<fpclassify> 526 527Returns one of 528 529 FP_NORMAL FP_ZERO FP_SUBNORMAL FP_INFINITE FP_NAN 530 531telling the class of the argument [C99]. C<FP_INFINITE> is positive 532or negative infinity, C<FP_NAN> is not-a-number. C<FP_SUBNORMAL> 533means subnormal numbers (also known as denormals), very small numbers 534with low precision. C<FP_ZERO> is zero. C<FP_NORMAL> is all the rest. 535 536=item C<fprintf> 537 538Not implemented. C<fprintf()> is C-specific, see L<perlfunc/printf> instead. 539 540=item C<fputc> 541 542Not implemented. C<fputc()> is C-specific, see L<perlfunc/print> instead. 543 544=item C<fputs> 545 546Not implemented. C<fputs()> is C-specific, see L<perlfunc/print> instead. 547 548=item C<fread> 549 550Not implemented. C<fread()> is C-specific, see L<perlfunc/read> instead. 551 552=item C<free> 553 554Not implemented. C<free()> is C-specific. Perl does memory management transparently. 555 556=item C<freopen> 557 558Not implemented. C<freopen()> is C-specific, see L<perlfunc/open> instead. 559 560=item C<frexp> 561 562Return the mantissa and exponent of a floating-point number. 563 564 ($mantissa, $exponent) = POSIX::frexp( 1.234e56 ); 565 566=item C<fscanf> 567 568Not implemented. C<fscanf()> is C-specific, use E<lt>E<gt> and regular expressions instead. 569 570=item C<fseek> 571 572Not implemented. Use method C<IO::Seekable::seek()> instead, or see L<perlfunc/seek>. 573 574=item C<fsetpos> 575 576Not implemented. Use method C<IO::Seekable::setpos()> instead, or seek L<perlfunc/seek>. 577 578=item C<fstat> 579 580Get file status. This uses file descriptors such as those obtained by 581calling C<POSIX::open>. The data returned is identical to the data from 582Perl's builtin C<stat> function. 583 584 $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); 585 @stats = POSIX::fstat( $fd ); 586 587=item C<fsync> 588 589Not implemented. Use method C<IO::Handle::sync()> instead. 590 591=item C<ftell> 592 593Not implemented. Use method C<IO::Seekable::tell()> instead, or see L<perlfunc/tell>. 594 595=item C<fwrite> 596 597Not implemented. C<fwrite()> is C-specific, see L<perlfunc/print> instead. 598 599=item C<getc> 600 601This is identical to Perl's builtin C<getc()> function, 602see L<perlfunc/getc>. 603 604=item C<getchar> 605 606Returns one character from STDIN. Identical to Perl's C<getc()>, 607see L<perlfunc/getc>. 608 609=item C<getcwd> 610 611Returns the name of the current working directory. 612See also L<Cwd>. 613 614=item C<getegid> 615 616Returns the effective group identifier. Similar to Perl' s builtin 617variable C<$(>, see L<perlvar/$EGID>. 618 619=item C<getenv> 620 621Returns the value of the specified environment variable. 622The same information is available through the C<%ENV> array. 623 624=item C<geteuid> 625 626Returns the effective user identifier. Identical to Perl's builtin C<$E<gt>> 627variable, see L<perlvar/$EUID>. 628 629=item C<getgid> 630 631Returns the user's real group identifier. Similar to Perl's builtin 632variable C<$)>, see L<perlvar/$GID>. 633 634=item C<getgrgid> 635 636This is identical to Perl's builtin C<getgrgid()> function for 637returning group entries by group identifiers, see 638L<perlfunc/getgrgid>. 639 640=item C<getgrnam> 641 642This is identical to Perl's builtin C<getgrnam()> function for 643returning group entries by group names, see L<perlfunc/getgrnam>. 644 645=item C<getgroups> 646 647Returns the ids of the user's supplementary groups. Similar to Perl's 648builtin variable C<$)>, see L<perlvar/$GID>. 649 650=item C<getlogin> 651 652This is identical to Perl's builtin C<getlogin()> function for 653returning the user name associated with the current session, see 654L<perlfunc/getlogin>. 655 656=item C<getpayload> 657 658 use POSIX ':nan_payload'; 659 getpayload($var) 660 661Returns the C<NaN> payload. 662 663Note the API instability warning in L</setpayload>. 664 665See L</nan> for more discussion about C<NaN>. 666 667=item C<getpgrp> 668 669This is identical to Perl's builtin C<getpgrp()> function for 670returning the process group identifier of the current process, see 671L<perlfunc/getpgrp>. 672 673=item C<getpid> 674 675Returns the process identifier. Identical to Perl's builtin 676variable C<$$>, see L<perlvar/$PID>. 677 678=item C<getppid> 679 680This is identical to Perl's builtin C<getppid()> function for 681returning the process identifier of the parent process of the current 682process , see L<perlfunc/getppid>. 683 684=item C<getpwnam> 685 686This is identical to Perl's builtin C<getpwnam()> function for 687returning user entries by user names, see L<perlfunc/getpwnam>. 688 689=item C<getpwuid> 690 691This is identical to Perl's builtin C<getpwuid()> function for 692returning user entries by user identifiers, see L<perlfunc/getpwuid>. 693 694=item C<gets> 695 696Returns one line from C<STDIN>, similar to E<lt>E<gt>, also known 697as the C<readline()> function, see L<perlfunc/readline>. 698 699B<NOTE>: if you have C programs that still use C<gets()>, be very 700afraid. The C<gets()> function is a source of endless grief because 701it has no buffer overrun checks. It should B<never> be used. The 702C<fgets()> function should be preferred instead. 703 704=item C<getuid> 705 706Returns the user's identifier. Identical to Perl's builtin C<$E<lt>> variable, 707see L<perlvar/$UID>. 708 709=item C<gmtime> 710 711This is identical to Perl's builtin C<gmtime()> function for 712converting seconds since the epoch to a date in Greenwich Mean Time, 713see L<perlfunc/gmtime>. 714 715=item C<hypot> 716 717Equivalent to C<S<sqrt(x * x + y * y)>> except more stable on very large 718or very small arguments [C99]. 719 720=item C<ilogb> 721 722Integer binary logarithm [C99] 723 724For example C<ilogb(20)> is 4, as an integer. 725 726See also L</logb>. 727 728=item C<Inf> 729 730The infinity as a constant: 731 732 use POSIX qw(Inf); 733 my $pos_inf = +Inf; # Or just Inf. 734 my $neg_inf = -Inf; 735 736See also L</isinf>, and L</fpclassify>. 737 738=item C<isalnum> 739 740This function has been removed as of v5.24. It was very similar to 741matching against S<C<qr/ ^ [[:alnum:]]+ $ /x>>, which you should convert 742to use instead. See L<perlrecharclass/POSIX Character Classes>. 743 744=item C<isalpha> 745 746This function has been removed as of v5.24. It was very similar to 747matching against S<C<qr/ ^ [[:alpha:]]+ $ /x>>, which you should convert 748to use instead. See L<perlrecharclass/POSIX Character Classes>. 749 750=item C<isatty> 751 752Returns a boolean indicating whether the specified filehandle is connected 753to a tty. Similar to the C<-t> operator, see L<perlfunc/-X>. 754 755=item C<iscntrl> 756 757This function has been removed as of v5.24. It was very similar to 758matching against S<C<qr/ ^ [[:cntrl:]]+ $ /x>>, which you should convert 759to use instead. See L<perlrecharclass/POSIX Character Classes>. 760 761=item C<isdigit> 762 763This function has been removed as of v5.24. It was very similar to 764matching against S<C<qr/ ^ [[:digit:]]+ $ /x>>, which you should convert 765to use instead. See L<perlrecharclass/POSIX Character Classes>. 766 767=item C<isfinite> 768 769Returns true if the argument is a finite number (that is, not an 770infinity, or the not-a-number) [C99]. 771 772See also L</isinf>, L</isnan>, and L</fpclassify>. 773 774=item C<isgraph> 775 776This function has been removed as of v5.24. It was very similar to 777matching against S<C<qr/ ^ [[:graph:]]+ $ /x>>, which you should convert 778to use instead. See L<perlrecharclass/POSIX Character Classes>. 779 780=item C<isgreater> 781 782(Also C<isgreaterequal>, C<isless>, C<islessequal>, C<islessgreater>, 783C<isunordered>) 784 785Floating point comparisons which handle the C<NaN> [C99]. 786 787=item C<isinf> 788 789Returns true if the argument is an infinity (positive or negative) [C99]. 790 791See also L</Inf>, L</isnan>, L</isfinite>, and L</fpclassify>. 792 793=item C<islower> 794 795This function has been removed as of v5.24. It was very similar to 796matching against S<C<qr/ ^ [[:lower:]]+ $ /x>>, which you should convert 797to use instead. See L<perlrecharclass/POSIX Character Classes>. 798 799=item C<isnan> 800 801Returns true if the argument is C<NaN> (not-a-number) [C99]. 802 803Note that you cannot test for "C<NaN>-ness" with 804 805 $x == $x 806 807since the C<NaN> is not equivalent to anything, B<including itself>. 808 809See also L</nan>, L</NaN>, L</isinf>, and L</fpclassify>. 810 811=item C<isnormal> 812 813Returns true if the argument is normal (that is, not a subnormal/denormal, 814and not an infinity, or a not-a-number) [C99]. 815 816See also L</isfinite>, and L</fpclassify>. 817 818=item C<isprint> 819 820This function has been removed as of v5.24. It was very similar to 821matching against S<C<qr/ ^ [[:print:]]+ $ /x>>, which you should convert 822to use instead. See L<perlrecharclass/POSIX Character Classes>. 823 824=item C<ispunct> 825 826This function has been removed as of v5.24. It was very similar to 827matching against S<C<qr/ ^ [[:punct:]]+ $ /x>>, which you should convert 828to use instead. See L<perlrecharclass/POSIX Character Classes>. 829 830=item C<issignaling> 831 832 use POSIX ':nan_payload'; 833 issignaling($var, $payload) 834 835Return true if the argument is a I<signaling> NaN. 836 837Note the API instability warning in L</setpayload>. 838 839See L</nan> for more discussion about C<NaN>. 840 841=item C<isspace> 842 843This function has been removed as of v5.24. It was very similar to 844matching against S<C<qr/ ^ [[:space:]]+ $ /x>>, which you should convert 845to use instead. See L<perlrecharclass/POSIX Character Classes>. 846 847=item C<isupper> 848 849This function has been removed as of v5.24. It was very similar to 850matching against S<C<qr/ ^ [[:upper:]]+ $ /x>>, which you should convert 851to use instead. See L<perlrecharclass/POSIX Character Classes>. 852 853=item C<isxdigit> 854 855This function has been removed as of v5.24. It was very similar to 856matching against S<C<qr/ ^ [[:xdigit:]]+ $ /x>>, which you should 857convert to use instead. See L<perlrecharclass/POSIX Character Classes>. 858 859=item C<j0> 860 861=item C<j1> 862 863=item C<jn> 864 865=item C<y0> 866 867=item C<y1> 868 869=item C<yn> 870 871The Bessel function of the first kind of the order zero. 872 873=item C<kill> 874 875This is identical to Perl's builtin C<kill()> function for sending 876signals to processes (often to terminate them), see L<perlfunc/kill>. 877 878=item C<labs> 879 880Not implemented. (For returning absolute values of long integers.) 881C<labs()> is C-specific, see L<perlfunc/abs> instead. 882 883=item C<lchown> 884 885This is identical to the C function, except the order of arguments is 886consistent with Perl's builtin C<chown()> with the added restriction 887of only one path, not a list of paths. Does the same thing as the 888C<chown()> function but changes the owner of a symbolic link instead 889of the file the symbolic link points to. 890 891 POSIX::lchown($uid, $gid, $file_path); 892 893=item C<ldexp> 894 895This is identical to the C function C<ldexp()> 896for multiplying floating point numbers with powers of two. 897 898 $x_quadrupled = POSIX::ldexp($x, 2); 899 900=item C<ldiv> 901 902Not implemented. (For computing dividends of long integers.) 903C<ldiv()> is C-specific, use C</> and C<int()> instead. 904 905=item C<lgamma> 906 907The logarithm of the Gamma function [C99]. 908 909See also L</tgamma>. 910 911=item C<log1p> 912 913Equivalent to S<C<log(1 + x)>>, but more stable results for small argument 914values [C99]. 915 916=item C<log2> 917 918Logarithm base two [C99]. 919 920See also L</expm1>. 921 922=item C<logb> 923 924Integer binary logarithm [C99]. 925 926For example C<logb(20)> is 4, as a floating point number. 927 928See also L</ilogb>. 929 930=item C<link> 931 932This is identical to Perl's builtin C<link()> function 933for creating hard links into files, see L<perlfunc/link>. 934 935=item C<localeconv> 936 937Get numeric formatting information. Returns a reference to a hash 938containing the current underlying locale's formatting values. Users of this function 939should also read L<perllocale>, which provides a comprehensive 940discussion of Perl locale handling, including 941L<a section devoted to this function|perllocale/The localeconv function>. 942Prior to Perl 5.28, or when operating in a non thread-safe environment, 943it should not be used in a threaded application unless it's certain that 944the underlying locale is C or POSIX. This is because it otherwise 945changes the locale, which globally affects all threads simultaneously. 946Windows platforms starting with Visual Studio 2005 are mostly 947thread-safe, but use of this function in those prior to Visual Studio 9482015 can interefere with a thread that has called 949L<perlapi/switch_to_global_locale>. 950 951Here is how to query the database for the B<de> (Deutsch or German) locale. 952 953 my $loc = POSIX::setlocale( &POSIX::LC_ALL, "de" ); 954 print "Locale: \"$loc\"\n"; 955 my $lconv = POSIX::localeconv(); 956 foreach my $property (qw( 957 decimal_point 958 thousands_sep 959 grouping 960 int_curr_symbol 961 currency_symbol 962 mon_decimal_point 963 mon_thousands_sep 964 mon_grouping 965 positive_sign 966 negative_sign 967 int_frac_digits 968 frac_digits 969 p_cs_precedes 970 p_sep_by_space 971 n_cs_precedes 972 n_sep_by_space 973 p_sign_posn 974 n_sign_posn 975 int_p_cs_precedes 976 int_p_sep_by_space 977 int_n_cs_precedes 978 int_n_sep_by_space 979 int_p_sign_posn 980 int_n_sign_posn 981 )) 982 { 983 printf qq(%s: "%s",\n), 984 $property, $lconv->{$property}; 985 } 986 987The members whose names begin with C<int_p_> and C<int_n_> were added by 988POSIX.1-2008 and are only available on systems that support them. 989 990=item C<localtime> 991 992This is identical to Perl's builtin C<localtime()> function for 993converting seconds since the epoch to a date see L<perlfunc/localtime> except 994that C<POSIX::localtime()> must be provided an explicit value (rather than 995relying on an implicit C<$_>): 996 997 @localtime = POSIX::localtime(time); # good 998 999 @localtime = localtime(); # good 1000 1001 @localtime = POSIX::localtime(); # throws exception 1002 1003=item C<log> 1004 1005This is identical to Perl's builtin C<log()> function, 1006returning the natural (I<e>-based) logarithm of the numerical argument, 1007see L<perlfunc/log>. 1008 1009=item C<log10> 1010 1011This is identical to the C function C<log10()>, 1012returning the 10-base logarithm of the numerical argument. 1013You can also use 1014 1015 sub log10 { log($_[0]) / log(10) } 1016 1017or 1018 1019 sub log10 { log($_[0]) / 2.30258509299405 } 1020 1021or 1022 1023 sub log10 { log($_[0]) * 0.434294481903252 } 1024 1025=item C<longjmp> 1026 1027Not implemented. C<longjmp()> is C-specific: use L<perlfunc/die> instead. 1028 1029=item C<lseek> 1030 1031Move the file's read/write position. This uses file descriptors such as 1032those obtained by calling C<POSIX::open>. 1033 1034 $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); 1035 $off_t = POSIX::lseek( $fd, 0, &POSIX::SEEK_SET ); 1036 1037Returns C<undef> on failure. 1038 1039=item C<lrint> 1040 1041Depending on the current floating point rounding mode, rounds the 1042argument either toward nearest (like L</round>), toward zero (like 1043L</trunc>), downward (toward negative infinity), or upward (toward 1044positive infinity) [C99]. 1045 1046For the rounding mode, see L</fegetround>. 1047 1048=item C<lround> 1049 1050Like L</round>, but as integer, as opposed to floating point [C99]. 1051 1052See also L</ceil>, L</floor>, L</trunc>. 1053 1054Owing to an oversight, this is not currently exported by default, or as part of 1055the C<:math_h_c99> export tag; importing it must therefore be done by explicit 1056name. 1057 1058=item C<malloc> 1059 1060Not implemented. C<malloc()> is C-specific. Perl does memory management transparently. 1061 1062=item C<mblen> 1063 1064This is identical to the C function C<mblen()>. 1065 1066Core Perl does not have any support for the wide and multibyte 1067characters of the C standards, except under UTF-8 locales, so this might 1068be a rather useless function. 1069 1070However, Perl supports Unicode, see L<perluniintro>. 1071 1072=item C<mbstowcs> 1073 1074This is identical to the C function C<mbstowcs()>. 1075 1076See L</mblen>. 1077 1078=item C<mbtowc> 1079 1080This is identical to the C function C<mbtowc()>. 1081 1082See L</mblen>. 1083 1084=item C<memchr> 1085 1086Not implemented. C<memchr()> is C-specific, see L<perlfunc/index> instead. 1087 1088=item C<memcmp> 1089 1090Not implemented. C<memcmp()> is C-specific, use C<eq> instead, see L<perlop>. 1091 1092=item C<memcpy> 1093 1094Not implemented. C<memcpy()> is C-specific, use C<=>, see L<perlop>, or see L<perlfunc/substr>. 1095 1096=item C<memmove> 1097 1098Not implemented. C<memmove()> is C-specific, use C<=>, see L<perlop>, or see L<perlfunc/substr>. 1099 1100=item C<memset> 1101 1102Not implemented. C<memset()> is C-specific, use C<x> instead, see L<perlop>. 1103 1104=item C<mkdir> 1105 1106This is identical to Perl's builtin C<mkdir()> function 1107for creating directories, see L<perlfunc/mkdir>. 1108 1109=item C<mkfifo> 1110 1111This is similar to the C function C<mkfifo()> for creating 1112FIFO special files. 1113 1114 if (mkfifo($path, $mode)) { .... 1115 1116Returns C<undef> on failure. The C<$mode> is similar to the 1117mode of C<mkdir()>, see L<perlfunc/mkdir>, though for C<mkfifo> 1118you B<must> specify the C<$mode>. 1119 1120=item C<mktime> 1121 1122Convert date/time info to a calendar time. 1123 1124Synopsis: 1125 1126 mktime(sec, min, hour, mday, mon, year, wday = 0, 1127 yday = 0, isdst = -1) 1128 1129The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero, 1130I<i.e.>, January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The 1131year (C<year>) is given in years since 1900; I<i.e.>, the year 1995 is 95; the 1132year 2001 is 101. Consult your system's C<mktime()> manpage for details 1133about these and the other arguments. 1134 1135Calendar time for December 12, 1995, at 10:30 am. 1136 1137 $time_t = POSIX::mktime( 0, 30, 10, 12, 11, 95 ); 1138 print "Date = ", POSIX::ctime($time_t); 1139 1140Returns C<undef> on failure. 1141 1142=item C<modf> 1143 1144Return the integral and fractional parts of a floating-point number. 1145 1146 ($fractional, $integral) = POSIX::modf( 3.14 ); 1147 1148See also L</round>. 1149 1150=item C<NaN> 1151 1152The not-a-number as a constant: 1153 1154 use POSIX qw(NaN); 1155 my $nan = NaN; 1156 1157See also L</nan>, C</isnan>, and L</fpclassify>. 1158 1159=item C<nan> 1160 1161 my $nan = nan(); 1162 1163Returns C<NaN>, not-a-number [C99]. 1164 1165The returned NaN is always a I<quiet> NaN, as opposed to I<signaling>. 1166 1167With an argument, can be used to generate a NaN with I<payload>. 1168The argument is first interpreted as a floating point number, 1169but then any fractional parts are truncated (towards zero), 1170and the value is interpreted as an unsigned integer. 1171The bits of this integer are stored in the unused bits of the NaN. 1172 1173The result has a dual nature: it is a NaN, but it also carries 1174the integer inside it. The integer can be retrieved with L</getpayload>. 1175Note, though, that the payload is not propagated, not even on copies, 1176and definitely not in arithmetic operations. 1177 1178How many bits fit in the NaN depends on what kind of floating points 1179are being used, but on the most common platforms (64-bit IEEE 754, 1180or the x86 80-bit long doubles) there are 51 and 61 bits available, 1181respectively. (There would be 52 and 62, but the quiet/signaling 1182bit of NaNs takes away one.) However, because of the floating-point-to- 1183integer-and-back conversions, please test carefully whether you get back 1184what you put in. If your integers are only 32 bits wide, you probably 1185should not rely on more than 32 bits of payload. 1186 1187Whether a "signaling" NaN is in any way different from a "quiet" NaN, 1188depends on the platform. Also note that the payload of the default 1189NaN (no argument to nan()) is not necessarily zero, use C<setpayload> 1190to explicitly set the payload. On some platforms like the 32-bit x86, 1191(unless using the 80-bit long doubles) the signaling bit is not supported 1192at all. 1193 1194See also L</isnan>, L</NaN>, L</setpayload> and L</issignaling>. 1195 1196=item C<nearbyint> 1197 1198Returns the nearest integer to the argument, according to the current 1199rounding mode (see L</fegetround>) [C99]. 1200 1201=item C<nextafter> 1202 1203Returns the next representable floating point number after C<x> in the 1204direction of C<y> [C99]. 1205 1206 my $nextafter = POSIX::nextafter($x, $y); 1207 1208Like L</nexttoward>, but potentially less accurate. 1209 1210=item C<nexttoward> 1211 1212Returns the next representable floating point number after C<x> in the 1213direction of C<y> [C99]. 1214 1215 my $nexttoward = POSIX::nexttoward($x, $y); 1216 1217Like L</nextafter>, but potentially more accurate. 1218 1219=item C<nice> 1220 1221This is similar to the C function C<nice()>, for changing 1222the scheduling preference of the current process. Positive 1223arguments mean a more polite process, negative values a more 1224needy process. Normal (non-root) user processes can only change towards 1225being more polite. 1226 1227Returns C<undef> on failure. 1228 1229=item C<offsetof> 1230 1231Not implemented. C<offsetof()> is C-specific, you probably want to see L<perlfunc/pack> instead. 1232 1233=item C<open> 1234 1235Open a file for reading for writing. This returns file descriptors, not 1236Perl filehandles. Use C<POSIX::close> to close the file. 1237 1238Open a file read-only with mode 0666. 1239 1240 $fd = POSIX::open( "foo" ); 1241 1242Open a file for read and write. 1243 1244 $fd = POSIX::open( "foo", &POSIX::O_RDWR ); 1245 1246Open a file for write, with truncation. 1247 1248 $fd = POSIX::open( 1249 "foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC 1250 ); 1251 1252Create a new file with mode 0640. Set up the file for writing. 1253 1254 $fd = POSIX::open( 1255 "foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0640 1256 ); 1257 1258Returns C<undef> on failure. 1259 1260See also L<perlfunc/sysopen>. 1261 1262=item C<opendir> 1263 1264Open a directory for reading. 1265 1266 $dir = POSIX::opendir( "/var" ); 1267 @files = POSIX::readdir( $dir ); 1268 POSIX::closedir( $dir ); 1269 1270Returns C<undef> on failure. 1271 1272=item C<pathconf> 1273 1274Retrieves the value of a configurable limit on a file or directory. 1275 1276The following will determine the maximum length of the longest allowable 1277pathname on the filesystem which holds C</var>. 1278 1279 $path_max = POSIX::pathconf( "/var", 1280 &POSIX::_PC_PATH_MAX ); 1281 1282Returns C<undef> on failure. 1283 1284=item C<pause> 1285 1286This is similar to the C function C<pause()>, which suspends 1287the execution of the current process until a signal is received. 1288 1289Returns C<undef> on failure. 1290 1291=item C<perror> 1292 1293This is identical to the C function C<perror()>, which outputs to the 1294standard error stream the specified message followed by C<": "> and the 1295current error string. Use the C<warn()> function and the C<$!> 1296variable instead, see L<perlfunc/warn> and L<perlvar/$ERRNO>. 1297 1298=item C<pipe> 1299 1300Create an interprocess channel. This returns file descriptors like those 1301returned by C<POSIX::open>. 1302 1303 my ($read, $write) = POSIX::pipe(); 1304 POSIX::write( $write, "hello", 5 ); 1305 POSIX::read( $read, $buf, 5 ); 1306 1307See also L<perlfunc/pipe>. 1308 1309=item C<pow> 1310 1311Computes C<$x> raised to the power C<$exponent>. 1312 1313 $ret = POSIX::pow( $x, $exponent ); 1314 1315You can also use the C<**> operator, see L<perlop>. 1316 1317=item C<printf> 1318 1319Formats and prints the specified arguments to C<STDOUT>. 1320See also L<perlfunc/printf>. 1321 1322=item C<putc> 1323 1324Not implemented. C<putc()> is C-specific, see L<perlfunc/print> instead. 1325 1326=item C<putchar> 1327 1328Not implemented. C<putchar()> is C-specific, see L<perlfunc/print> instead. 1329 1330=item C<puts> 1331 1332Not implemented. C<puts()> is C-specific, see L<perlfunc/print> instead. 1333 1334=item C<qsort> 1335 1336Not implemented. C<qsort()> is C-specific, see L<perlfunc/sort> instead. 1337 1338=item C<raise> 1339 1340Sends the specified signal to the current process. 1341See also L<perlfunc/kill> and the C<$$> in L<perlvar/$PID>. 1342 1343=item C<rand> 1344 1345Not implemented. C<rand()> is non-portable, see L<perlfunc/rand> instead. 1346 1347=item C<read> 1348 1349Read from a file. This uses file descriptors such as those obtained by 1350calling C<POSIX::open>. If the buffer C<$buf> is not large enough for the 1351read then Perl will extend it to make room for the request. 1352 1353 $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); 1354 $bytes = POSIX::read( $fd, $buf, 3 ); 1355 1356Returns C<undef> on failure. 1357 1358See also L<perlfunc/sysread>. 1359 1360=item C<readdir> 1361 1362This is identical to Perl's builtin C<readdir()> function 1363for reading directory entries, see L<perlfunc/readdir>. 1364 1365=item C<realloc> 1366 1367Not implemented. C<realloc()> is C-specific. Perl does memory management transparently. 1368 1369=item C<remainder> 1370 1371Given C<x> and C<y>, returns the value S<C<x - n*y>>, where C<n> is the integer 1372closest to C<x>/C<y>. [C99] 1373 1374 my $remainder = POSIX::remainder($x, $y) 1375 1376See also L</remquo>. 1377 1378=item C<remove> 1379 1380This is identical to Perl's builtin C<unlink()> function 1381for removing files, see L<perlfunc/unlink>. 1382 1383=item C<remquo> 1384 1385Like L</remainder> but also returns the low-order bits of the quotient (n) 1386[C99] 1387 1388(This is quite esoteric interface, mainly used to implement numerical 1389algorithms.) 1390 1391=item C<rename> 1392 1393This is identical to Perl's builtin C<rename()> function 1394for renaming files, see L<perlfunc/rename>. 1395 1396=item C<rewind> 1397 1398Seeks to the beginning of the file. 1399 1400=item C<rewinddir> 1401 1402This is identical to Perl's builtin C<rewinddir()> function for 1403rewinding directory entry streams, see L<perlfunc/rewinddir>. 1404 1405=item C<rint> 1406 1407Identical to L</lrint>. 1408 1409=item C<rmdir> 1410 1411This is identical to Perl's builtin C<rmdir()> function 1412for removing (empty) directories, see L<perlfunc/rmdir>. 1413 1414=item C<round> 1415 1416Returns the integer (but still as floating point) nearest to the 1417argument [C99]. 1418 1419See also L</ceil>, L</floor>, L</lround>, L</modf>, and L</trunc>. 1420 1421=item C<scalbn> 1422 1423Returns S<C<x * 2**y>> [C99]. 1424 1425See also L</frexp> and L</ldexp>. 1426 1427=item C<scanf> 1428 1429Not implemented. C<scanf()> is C-specific, use E<lt>E<gt> and regular expressions instead, 1430see L<perlre>. 1431 1432=item C<setgid> 1433 1434Sets the real group identifier and the effective group identifier for 1435this process. Similar to assigning a value to the Perl's builtin 1436C<$)> variable, see L<perlvar/$EGID>, except that the latter 1437will change only the real user identifier, and that the setgid() 1438uses only a single numeric argument, as opposed to a space-separated 1439list of numbers. 1440 1441=item C<setjmp> 1442 1443Not implemented. C<setjmp()> is C-specific: use C<eval {}> instead, 1444see L<perlfunc/eval>. 1445 1446=item C<setlocale> 1447 1448WARNING! Do NOT use this function in a L<thread|threads>. The locale 1449will change in all other threads at the same time, and should your 1450thread get paused by the operating system, and another started, that 1451thread will not have the locale it is expecting. On some platforms, 1452there can be a race leading to segfaults if two threads call this 1453function nearly simultaneously. 1454 1455Modifies and queries the program's underlying locale. Users of this 1456function should read L<perllocale>, whch provides a comprehensive 1457discussion of Perl locale handling, knowledge of which is necessary to 1458properly use this function. It contains 1459L<a section devoted to this function|perllocale/The setlocale function>. 1460The discussion here is merely a summary reference for C<setlocale()>. 1461Note that Perl itself is almost entirely unaffected by the locale 1462except within the scope of S<C<"use locale">>. (Exceptions are listed 1463in L<perllocale/Not within the scope of "use locale">.) 1464 1465The following examples assume 1466 1467 use POSIX qw(setlocale LC_ALL LC_CTYPE); 1468 1469has been issued. 1470 1471The following will set the traditional UNIX system locale behavior 1472(the second argument C<"C">). 1473 1474 $loc = setlocale( LC_ALL, "C" ); 1475 1476The following will query the current C<LC_CTYPE> category. (No second 1477argument means 'query'.) 1478 1479 $loc = setlocale( LC_CTYPE ); 1480 1481The following will set the C<LC_CTYPE> behaviour according to the locale 1482environment variables (the second argument C<"">). 1483Please see your system's C<setlocale(3)> documentation for the locale 1484environment variables' meaning or consult L<perllocale>. 1485 1486 $loc = setlocale( LC_CTYPE, "" ); 1487 1488The following will set the C<LC_COLLATE> behaviour to Argentinian 1489Spanish. B<NOTE>: The naming and availability of locales depends on 1490your operating system. Please consult L<perllocale> for how to find 1491out which locales are available in your system. 1492 1493 $loc = setlocale( LC_COLLATE, "es_AR.ISO8859-1" ); 1494 1495=item C<setpayload> 1496 1497 use POSIX ':nan_payload'; 1498 setpayload($var, $payload); 1499 1500Sets the C<NaN> payload of var. 1501 1502NOTE: the NaN payload APIs are based on the latest (as of June 2015) 1503proposed ISO C interfaces, but they are not yet a standard. Things 1504may change. 1505 1506See L</nan> for more discussion about C<NaN>. 1507 1508See also L</setpayloadsig>, L</isnan>, L</getpayload>, and L</issignaling>. 1509 1510=item C<setpayloadsig> 1511 1512 use POSIX ':nan_payload'; 1513 setpayloadsig($var, $payload); 1514 1515Like L</setpayload> but also makes the NaN I<signaling>. 1516 1517Depending on the platform the NaN may or may not behave differently. 1518 1519Note the API instability warning in L</setpayload>. 1520 1521Note that because how the floating point formats work out, on the most 1522common platforms signaling payload of zero is best avoided, 1523since it might end up being identical to C<+Inf>. 1524 1525See also L</nan>, L</isnan>, L</getpayload>, and L</issignaling>. 1526 1527=item C<setpgid> 1528 1529This is similar to the C function C<setpgid()> for 1530setting the process group identifier of the current process. 1531 1532Returns C<undef> on failure. 1533 1534=item C<setsid> 1535 1536This is identical to the C function C<setsid()> for 1537setting the session identifier of the current process. 1538 1539=item C<setuid> 1540 1541Sets the real user identifier and the effective user identifier for 1542this process. Similar to assigning a value to the Perl's builtin 1543C<$E<lt>> variable, see L<perlvar/$UID>, except that the latter 1544will change only the real user identifier. 1545 1546=item C<sigaction> 1547 1548Detailed signal management. This uses C<POSIX::SigAction> objects for 1549the C<action> and C<oldaction> arguments (the oldaction can also be 1550just a hash reference). Consult your system's C<sigaction> manpage 1551for details, see also C<POSIX::SigRt>. 1552 1553Synopsis: 1554 1555 sigaction(signal, action, oldaction = 0) 1556 1557Returns C<undef> on failure. The C<signal> must be a number (like 1558C<SIGHUP>), not a string (like C<"SIGHUP">), though Perl does try hard 1559to understand you. 1560 1561If you use the C<SA_SIGINFO> flag, the signal handler will in addition to 1562the first argument, the signal name, also receive a second argument, a 1563hash reference, inside which are the following keys with the following 1564semantics, as defined by POSIX/SUSv3: 1565 1566 signo the signal number 1567 errno the error number 1568 code if this is zero or less, the signal was sent by 1569 a user process and the uid and pid make sense, 1570 otherwise the signal was sent by the kernel 1571 1572The constants for specific C<code> values can be imported individually 1573or using the C<:signal_h_si_code> tag. 1574 1575The following are also defined by POSIX/SUSv3, but unfortunately 1576not very widely implemented: 1577 1578 pid the process id generating the signal 1579 uid the uid of the process id generating the signal 1580 status exit value or signal for SIGCHLD 1581 band band event for SIGPOLL 1582 addr address of faulting instruction or memory 1583 reference for SIGILL, SIGFPE, SIGSEGV or SIGBUS 1584 1585A third argument is also passed to the handler, which contains a copy 1586of the raw binary contents of the C<siginfo> structure: if a system has 1587some non-POSIX fields, this third argument is where to C<unpack()> them 1588from. 1589 1590Note that not all C<siginfo> values make sense simultaneously (some are 1591valid only for certain signals, for example), and not all values make 1592sense from Perl perspective, you should to consult your system's 1593C<sigaction> and possibly also C<siginfo> documentation. 1594 1595=item C<siglongjmp> 1596 1597Not implemented. C<siglongjmp()> is C-specific: use L<perlfunc/die> instead. 1598 1599=item C<signbit> 1600 1601Returns zero for positive arguments, non-zero for negative arguments [C99]. 1602 1603=item C<sigpending> 1604 1605Examine signals that are blocked and pending. This uses C<POSIX::SigSet> 1606objects for the C<sigset> argument. Consult your system's C<sigpending> 1607manpage for details. 1608 1609Synopsis: 1610 1611 sigpending(sigset) 1612 1613Returns C<undef> on failure. 1614 1615=item C<sigprocmask> 1616 1617Change and/or examine calling process's signal mask. This uses 1618C<POSIX::SigSet> objects for the C<sigset> and C<oldsigset> arguments. 1619Consult your system's C<sigprocmask> manpage for details. 1620 1621Synopsis: 1622 1623 sigprocmask(how, sigset, oldsigset = 0) 1624 1625Returns C<undef> on failure. 1626 1627Note that you can't reliably block or unblock a signal from its own signal 1628handler if you're using safe signals. Other signals can be blocked or unblocked 1629reliably. 1630 1631=item C<sigsetjmp> 1632 1633Not implemented. C<sigsetjmp()> is C-specific: use C<eval {}> instead, 1634see L<perlfunc/eval>. 1635 1636=item C<sigsuspend> 1637 1638Install a signal mask and suspend process until signal arrives. This uses 1639C<POSIX::SigSet> objects for the C<signal_mask> argument. Consult your 1640system's C<sigsuspend> manpage for details. 1641 1642Synopsis: 1643 1644 sigsuspend(signal_mask) 1645 1646Returns C<undef> on failure. 1647 1648=item C<sin> 1649 1650This is identical to Perl's builtin C<sin()> function 1651for returning the sine of the numerical argument, 1652see L<perlfunc/sin>. See also L<Math::Trig>. 1653 1654=item C<sinh> 1655 1656This is identical to the C function C<sinh()> 1657for returning the hyperbolic sine of the numerical argument. 1658See also L<Math::Trig>. 1659 1660=item C<sleep> 1661 1662This is functionally identical to Perl's builtin C<sleep()> function 1663for suspending the execution of the current for process for certain 1664number of seconds, see L<perlfunc/sleep>. There is one significant 1665difference, however: C<POSIX::sleep()> returns the number of 1666B<unslept> seconds, while the C<CORE::sleep()> returns the 1667number of slept seconds. 1668 1669=item C<sprintf> 1670 1671This is similar to Perl's builtin C<sprintf()> function 1672for returning a string that has the arguments formatted as requested, 1673see L<perlfunc/sprintf>. 1674 1675=item C<sqrt> 1676 1677This is identical to Perl's builtin C<sqrt()> function. 1678for returning the square root of the numerical argument, 1679see L<perlfunc/sqrt>. 1680 1681=item C<srand> 1682 1683Give a seed the pseudorandom number generator, see L<perlfunc/srand>. 1684 1685=item C<sscanf> 1686 1687Not implemented. C<sscanf()> is C-specific, use regular expressions instead, 1688see L<perlre>. 1689 1690=item C<stat> 1691 1692This is identical to Perl's builtin C<stat()> function 1693for returning information about files and directories. 1694 1695=item C<strcat> 1696 1697Not implemented. C<strcat()> is C-specific, use C<.=> instead, see L<perlop>. 1698 1699=item C<strchr> 1700 1701Not implemented. C<strchr()> is C-specific, see L<perlfunc/index> instead. 1702 1703=item C<strcmp> 1704 1705Not implemented. C<strcmp()> is C-specific, use C<eq> or C<cmp> instead, see L<perlop>. 1706 1707=item C<strcoll> 1708 1709This is identical to the C function C<strcoll()> 1710for collating (comparing) strings transformed using 1711the C<strxfrm()> function. Not really needed since 1712Perl can do this transparently, see L<perllocale>. 1713 1714Beware that in a UTF-8 locale, anything you pass to this function must 1715be in UTF-8; and when not in a UTF-8 locale, anything passed must not be 1716UTF-8 encoded. 1717 1718=item C<strcpy> 1719 1720Not implemented. C<strcpy()> is C-specific, use C<=> instead, see L<perlop>. 1721 1722=item C<strcspn> 1723 1724Not implemented. C<strcspn()> is C-specific, use regular expressions instead, 1725see L<perlre>. 1726 1727=item C<strerror> 1728 1729Returns the error string for the specified errno. 1730Identical to the string form of C<$!>, see L<perlvar/$ERRNO>. 1731 1732=item C<strftime> 1733 1734Convert date and time information to string. Returns the string. 1735 1736Synopsis: 1737 1738 strftime(fmt, sec, min, hour, mday, mon, year, 1739 wday = -1, yday = -1, isdst = -1) 1740 1741The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero, 1742I<i.e.>, January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The 1743year (C<year>) is given in years since 1900, I<i.e.>, the year 1995 is 95; the 1744year 2001 is 101. Consult your system's C<strftime()> manpage for details 1745about these and the other arguments. 1746 1747If you want your code to be portable, your format (C<fmt>) argument 1748should use only the conversion specifiers defined by the ANSI C 1749standard (C89, to play safe). These are C<aAbBcdHIjmMpSUwWxXyYZ%>. 1750But even then, the B<results> of some of the conversion specifiers are 1751non-portable. For example, the specifiers C<aAbBcpZ> change according 1752to the locale settings of the user, and both how to set locales (the 1753locale names) and what output to expect are non-standard. 1754The specifier C<c> changes according to the timezone settings of the 1755user and the timezone computation rules of the operating system. 1756The C<Z> specifier is notoriously unportable since the names of 1757timezones are non-standard. Sticking to the numeric specifiers is the 1758safest route. 1759 1760The given arguments are made consistent as though by calling 1761C<mktime()> before calling your system's C<strftime()> function, 1762except that the C<isdst> value is not affected. 1763 1764The string for Tuesday, December 12, 1995. 1765 1766 $str = POSIX::strftime( "%A, %B %d, %Y", 1767 0, 0, 0, 12, 11, 95, 2 ); 1768 print "$str\n"; 1769 1770=item C<strlen> 1771 1772Not implemented. C<strlen()> is C-specific, use C<length()> instead, see L<perlfunc/length>. 1773 1774=item C<strncat> 1775 1776Not implemented. C<strncat()> is C-specific, use C<.=> instead, see L<perlop>. 1777 1778=item C<strncmp> 1779 1780Not implemented. C<strncmp()> is C-specific, use C<eq> instead, see L<perlop>. 1781 1782=item C<strncpy> 1783 1784Not implemented. C<strncpy()> is C-specific, use C<=> instead, see L<perlop>. 1785 1786=item C<strpbrk> 1787 1788Not implemented. C<strpbrk()> is C-specific, use regular expressions instead, 1789see L<perlre>. 1790 1791=item C<strrchr> 1792 1793Not implemented. C<strrchr()> is C-specific, see L<perlfunc/rindex> instead. 1794 1795=item C<strspn> 1796 1797Not implemented. C<strspn()> is C-specific, use regular expressions instead, 1798see L<perlre>. 1799 1800=item C<strstr> 1801 1802This is identical to Perl's builtin C<index()> function, 1803see L<perlfunc/index>. 1804 1805=item C<strtod> 1806 1807String to double translation. Returns the parsed number and the number 1808of characters in the unparsed portion of the string. Truly 1809POSIX-compliant systems set C<$!> (C<$ERRNO>) to indicate a translation 1810error, so clear C<$!> before calling C<strtod>. However, non-POSIX systems 1811may not check for overflow, and therefore will never set C<$!>. 1812 1813C<strtod> respects any POSIX C<setlocale()> C<LC_TIME> settings, 1814regardless of whether or not it is called from Perl code that is within 1815the scope of S<C<use locale>>. This means it should not be used in a 1816threaded application unless it's certain that the underlying locale is C 1817or POSIX. This is because it otherwise changes the locale, which 1818globally affects all threads simultaneously. 1819 1820To parse a string C<$str> as a floating point number use 1821 1822 $! = 0; 1823 ($num, $n_unparsed) = POSIX::strtod($str); 1824 1825The second returned item and C<$!> can be used to check for valid input: 1826 1827 if (($str eq '') || ($n_unparsed != 0) || $!) { 1828 die "Non-numeric input $str" . ($! ? ": $!\n" : "\n"); 1829 } 1830 1831When called in a scalar context C<strtod> returns the parsed number. 1832 1833=item C<strtok> 1834 1835Not implemented. C<strtok()> is C-specific, use regular expressions instead, see 1836L<perlre>, or L<perlfunc/split>. 1837 1838=item C<strtol> 1839 1840String to (long) integer translation. Returns the parsed number and 1841the number of characters in the unparsed portion of the string. Truly 1842POSIX-compliant systems set C<$!> (C<$ERRNO>) to indicate a translation 1843error, so clear C<$!> before calling C<strtol>. However, non-POSIX systems 1844may not check for overflow, and therefore will never set C<$!>. 1845 1846C<strtol> should respect any POSIX I<setlocale()> settings. 1847 1848To parse a string C<$str> as a number in some base C<$base> use 1849 1850 $! = 0; 1851 ($num, $n_unparsed) = POSIX::strtol($str, $base); 1852 1853The base should be zero or between 2 and 36, inclusive. When the base 1854is zero or omitted C<strtol> will use the string itself to determine the 1855base: a leading "0x" or "0X" means hexadecimal; a leading "0" means 1856octal; any other leading characters mean decimal. Thus, "1234" is 1857parsed as a decimal number, "01234" as an octal number, and "0x1234" 1858as a hexadecimal number. 1859 1860The second returned item and C<$!> can be used to check for valid input: 1861 1862 if (($str eq '') || ($n_unparsed != 0) || !$!) { 1863 die "Non-numeric input $str" . $! ? ": $!\n" : "\n"; 1864 } 1865 1866When called in a scalar context C<strtol> returns the parsed number. 1867 1868=item C<strtold> 1869 1870Like L</strtod> but for long doubles. Defined only if the 1871system supports long doubles. 1872 1873=item C<strtoul> 1874 1875String to unsigned (long) integer translation. C<strtoul()> is identical 1876to C<strtol()> except that C<strtoul()> only parses unsigned integers. See 1877L</strtol> for details. 1878 1879Note: Some vendors supply C<strtod()> and C<strtol()> but not C<strtoul()>. 1880Other vendors that do supply C<strtoul()> parse "-1" as a valid value. 1881 1882=item C<strxfrm> 1883 1884String transformation. Returns the transformed string. 1885 1886 $dst = POSIX::strxfrm( $src ); 1887 1888Used in conjunction with the C<strcoll()> function, see L</strcoll>. 1889 1890Not really needed since Perl can do this transparently, see 1891L<perllocale>. 1892 1893Beware that in a UTF-8 locale, anything you pass to this function must 1894be in UTF-8; and when not in a UTF-8 locale, anything passed must not be 1895UTF-8 encoded. 1896 1897=item C<sysconf> 1898 1899Retrieves values of system configurable variables. 1900 1901The following will get the machine's clock speed. 1902 1903 $clock_ticks = POSIX::sysconf( &POSIX::_SC_CLK_TCK ); 1904 1905Returns C<undef> on failure. 1906 1907=item C<system> 1908 1909This is identical to Perl's builtin C<system()> function, see 1910L<perlfunc/system>. 1911 1912=item C<tan> 1913 1914This is identical to the C function C<tan()>, returning the 1915tangent of the numerical argument. See also L<Math::Trig>. 1916 1917=item C<tanh> 1918 1919This is identical to the C function C<tanh()>, returning the 1920hyperbolic tangent of the numerical argument. See also L<Math::Trig>. 1921 1922=item C<tcdrain> 1923 1924This is similar to the C function C<tcdrain()> for draining 1925the output queue of its argument stream. 1926 1927Returns C<undef> on failure. 1928 1929=item C<tcflow> 1930 1931This is similar to the C function C<tcflow()> for controlling 1932the flow of its argument stream. 1933 1934Returns C<undef> on failure. 1935 1936=item C<tcflush> 1937 1938This is similar to the C function C<tcflush()> for flushing 1939the I/O buffers of its argument stream. 1940 1941Returns C<undef> on failure. 1942 1943=item C<tcgetpgrp> 1944 1945This is identical to the C function C<tcgetpgrp()> for returning the 1946process group identifier of the foreground process group of the controlling 1947terminal. 1948 1949=item C<tcsendbreak> 1950 1951This is similar to the C function C<tcsendbreak()> for sending 1952a break on its argument stream. 1953 1954Returns C<undef> on failure. 1955 1956=item C<tcsetpgrp> 1957 1958This is similar to the C function C<tcsetpgrp()> for setting the 1959process group identifier of the foreground process group of the controlling 1960terminal. 1961 1962Returns C<undef> on failure. 1963 1964=item C<tgamma> 1965 1966The Gamma function [C99]. 1967 1968See also L</lgamma>. 1969 1970=item C<time> 1971 1972This is identical to Perl's builtin C<time()> function 1973for returning the number of seconds since the epoch 1974(whatever it is for the system), see L<perlfunc/time>. 1975 1976=item C<times> 1977 1978The C<times()> function returns elapsed realtime since some point in the past 1979(such as system startup), user and system times for this process, and user 1980and system times used by child processes. All times are returned in clock 1981ticks. 1982 1983 ($realtime, $user, $system, $cuser, $csystem) 1984 = POSIX::times(); 1985 1986Note: Perl's builtin C<times()> function returns four values, measured in 1987seconds. 1988 1989=item C<tmpfile> 1990 1991Not implemented. Use method C<IO::File::new_tmpfile()> instead, or see L<File::Temp>. 1992 1993=item C<tmpnam> 1994 1995For security reasons, which are probably detailed in your system's 1996documentation for the C library C<tmpnam()> function, this interface 1997is no longer available; instead use L<File::Temp>. 1998 1999=item C<tolower> 2000 2001This is identical to the C function, except that it can apply to a single 2002character or to a whole string, and currently operates as if the locale 2003always is "C". Consider using the C<lc()> function, see L<perlfunc/lc>, 2004see L<perlfunc/lc>, or the equivalent C<\L> operator inside doublequotish 2005strings. 2006 2007=item C<toupper> 2008 2009This is similar to the C function, except that it can apply to a single 2010character or to a whole string, and currently operates as if the locale 2011always is "C". Consider using the C<uc()> function, see L<perlfunc/uc>, 2012or the equivalent C<\U> operator inside doublequotish strings. 2013 2014=item C<trunc> 2015 2016Returns the integer toward zero from the argument [C99]. 2017 2018See also L</ceil>, L</floor>, and L</round>. 2019 2020=item C<ttyname> 2021 2022This is identical to the C function C<ttyname()> for returning the 2023name of the current terminal. 2024 2025=item C<tzname> 2026 2027Retrieves the time conversion information from the C<tzname> variable. 2028 2029 POSIX::tzset(); 2030 ($std, $dst) = POSIX::tzname(); 2031 2032=item C<tzset> 2033 2034This is identical to the C function C<tzset()> for setting 2035the current timezone based on the environment variable C<TZ>, 2036to be used by C<ctime()>, C<localtime()>, C<mktime()>, and C<strftime()> 2037functions. 2038 2039=item C<umask> 2040 2041This is identical to Perl's builtin C<umask()> function 2042for setting (and querying) the file creation permission mask, 2043see L<perlfunc/umask>. 2044 2045=item C<uname> 2046 2047Get name of current operating system. 2048 2049 ($sysname, $nodename, $release, $version, $machine) 2050 = POSIX::uname(); 2051 2052Note that the actual meanings of the various fields are not 2053that well standardized, do not expect any great portability. 2054The C<$sysname> might be the name of the operating system, 2055the C<$nodename> might be the name of the host, the C<$release> 2056might be the (major) release number of the operating system, 2057the C<$version> might be the (minor) release number of the 2058operating system, and the C<$machine> might be a hardware identifier. 2059Maybe. 2060 2061=item C<ungetc> 2062 2063Not implemented. Use method C<IO::Handle::ungetc()> instead. 2064 2065=item C<unlink> 2066 2067This is identical to Perl's builtin C<unlink()> function 2068for removing files, see L<perlfunc/unlink>. 2069 2070=item C<utime> 2071 2072This is identical to Perl's builtin C<utime()> function 2073for changing the time stamps of files and directories, 2074see L<perlfunc/utime>. 2075 2076=item C<vfprintf> 2077 2078Not implemented. C<vfprintf()> is C-specific, see L<perlfunc/printf> instead. 2079 2080=item C<vprintf> 2081 2082Not implemented. C<vprintf()> is C-specific, see L<perlfunc/printf> instead. 2083 2084=item C<vsprintf> 2085 2086Not implemented. C<vsprintf()> is C-specific, see L<perlfunc/sprintf> instead. 2087 2088=item C<wait> 2089 2090This is identical to Perl's builtin C<wait()> function, 2091see L<perlfunc/wait>. 2092 2093=item C<waitpid> 2094 2095Wait for a child process to change state. This is identical to Perl's 2096builtin C<waitpid()> function, see L<perlfunc/waitpid>. 2097 2098 $pid = POSIX::waitpid( -1, POSIX::WNOHANG ); 2099 print "status = ", ($? / 256), "\n"; 2100 2101=item C<wcstombs> 2102 2103This is identical to the C function C<wcstombs()>. 2104 2105See L</mblen>. 2106 2107=item C<wctomb> 2108 2109This is identical to the C function C<wctomb()>. 2110 2111See L</mblen>. 2112 2113=item C<write> 2114 2115Write to a file. This uses file descriptors such as those obtained by 2116calling C<POSIX::open>. 2117 2118 $fd = POSIX::open( "foo", &POSIX::O_WRONLY ); 2119 $buf = "hello"; 2120 $bytes = POSIX::write( $fd, $buf, 5 ); 2121 2122Returns C<undef> on failure. 2123 2124See also L<perlfunc/syswrite>. 2125 2126=back 2127 2128=head1 CLASSES 2129 2130=head2 C<POSIX::SigAction> 2131 2132=over 8 2133 2134=item C<new> 2135 2136Creates a new C<POSIX::SigAction> object which corresponds to the C 2137C<struct sigaction>. This object will be destroyed automatically when 2138it is no longer needed. The first parameter is the handler, a sub 2139reference. The second parameter is a C<POSIX::SigSet> object, it 2140defaults to the empty set. The third parameter contains the 2141C<sa_flags>, it defaults to 0. 2142 2143 $sigset = POSIX::SigSet->new(SIGINT, SIGQUIT); 2144 $sigaction = POSIX::SigAction->new( 2145 \&handler, $sigset, &POSIX::SA_NOCLDSTOP 2146 ); 2147 2148This C<POSIX::SigAction> object is intended for use with the C<POSIX::sigaction()> 2149function. 2150 2151=back 2152 2153=over 8 2154 2155=item C<handler> 2156 2157=item C<mask> 2158 2159=item C<flags> 2160 2161accessor functions to get/set the values of a SigAction object. 2162 2163 $sigset = $sigaction->mask; 2164 $sigaction->flags(&POSIX::SA_RESTART); 2165 2166=item C<safe> 2167 2168accessor function for the "safe signals" flag of a SigAction object; see 2169L<perlipc> for general information on safe (a.k.a. "deferred") signals. If 2170you wish to handle a signal safely, use this accessor to set the "safe" flag 2171in the C<POSIX::SigAction> object: 2172 2173 $sigaction->safe(1); 2174 2175You may also examine the "safe" flag on the output action object which is 2176filled in when given as the third parameter to C<POSIX::sigaction()>: 2177 2178 sigaction(SIGINT, $new_action, $old_action); 2179 if ($old_action->safe) { 2180 # previous SIGINT handler used safe signals 2181 } 2182 2183=back 2184 2185=head2 C<POSIX::SigRt> 2186 2187=over 8 2188 2189=item C<%SIGRT> 2190 2191A hash of the POSIX realtime signal handlers. It is an extension of 2192the standard C<%SIG>, the C<$POSIX::SIGRT{SIGRTMIN}> is roughly equivalent 2193to C<$SIG{SIGRTMIN}>, but the right POSIX moves (see below) are made with 2194the C<POSIX::SigSet> and C<POSIX::sigaction> instead of accessing the C<%SIG>. 2195 2196You can set the C<%POSIX::SIGRT> elements to set the POSIX realtime 2197signal handlers, use C<delete> and C<exists> on the elements, and use 2198C<scalar> on the C<%POSIX::SIGRT> to find out how many POSIX realtime 2199signals there are available S<C<(SIGRTMAX - SIGRTMIN + 1>>, the C<SIGRTMAX> is 2200a valid POSIX realtime signal). 2201 2202Setting the C<%SIGRT> elements is equivalent to calling this: 2203 2204 sub new { 2205 my ($rtsig, $handler, $flags) = @_; 2206 my $sigset = POSIX::SigSet($rtsig); 2207 my $sigact = POSIX::SigAction->new($handler,$sigset,$flags); 2208 sigaction($rtsig, $sigact); 2209 } 2210 2211The flags default to zero, if you want something different you can 2212either use C<local> on C<$POSIX::SigRt::SIGACTION_FLAGS>, or you can 2213derive from POSIX::SigRt and define your own C<new()> (the tied hash 2214STORE method of the C<%SIGRT> calls C<new($rtsig, $handler, $SIGACTION_FLAGS)>, 2215where the C<$rtsig> ranges from zero to S<C<SIGRTMAX - SIGRTMIN + 1)>>. 2216 2217Just as with any signal, you can use C<sigaction($rtsig, undef, $oa)> to 2218retrieve the installed signal handler (or, rather, the signal action). 2219 2220B<NOTE:> whether POSIX realtime signals really work in your system, or 2221whether Perl has been compiled so that it works with them, is outside 2222of this discussion. 2223 2224=item C<SIGRTMIN> 2225 2226Return the minimum POSIX realtime signal number available, or C<undef> 2227if no POSIX realtime signals are available. 2228 2229=item C<SIGRTMAX> 2230 2231Return the maximum POSIX realtime signal number available, or C<undef> 2232if no POSIX realtime signals are available. 2233 2234=back 2235 2236=head2 C<POSIX::SigSet> 2237 2238=over 8 2239 2240=item C<new> 2241 2242Create a new SigSet object. This object will be destroyed automatically 2243when it is no longer needed. Arguments may be supplied to initialize the 2244set. 2245 2246Create an empty set. 2247 2248 $sigset = POSIX::SigSet->new; 2249 2250Create a set with C<SIGUSR1>. 2251 2252 $sigset = POSIX::SigSet->new( &POSIX::SIGUSR1 ); 2253 2254=item C<addset> 2255 2256Add a signal to a SigSet object. 2257 2258 $sigset->addset( &POSIX::SIGUSR2 ); 2259 2260Returns C<undef> on failure. 2261 2262=item C<delset> 2263 2264Remove a signal from the SigSet object. 2265 2266 $sigset->delset( &POSIX::SIGUSR2 ); 2267 2268Returns C<undef> on failure. 2269 2270=item C<emptyset> 2271 2272Initialize the SigSet object to be empty. 2273 2274 $sigset->emptyset(); 2275 2276Returns C<undef> on failure. 2277 2278=item C<fillset> 2279 2280Initialize the SigSet object to include all signals. 2281 2282 $sigset->fillset(); 2283 2284Returns C<undef> on failure. 2285 2286=item C<ismember> 2287 2288Tests the SigSet object to see if it contains a specific signal. 2289 2290 if( $sigset->ismember( &POSIX::SIGUSR1 ) ){ 2291 print "contains SIGUSR1\n"; 2292 } 2293 2294=back 2295 2296=head2 C<POSIX::Termios> 2297 2298=over 8 2299 2300=item C<new> 2301 2302Create a new Termios object. This object will be destroyed automatically 2303when it is no longer needed. A Termios object corresponds to the C<termios> 2304C struct. C<new()> mallocs a new one, C<getattr()> fills it from a file descriptor, 2305and C<setattr()> sets a file descriptor's parameters to match Termios' contents. 2306 2307 $termios = POSIX::Termios->new; 2308 2309=item C<getattr> 2310 2311Get terminal control attributes. 2312 2313Obtain the attributes for C<stdin>. 2314 2315 $termios->getattr( 0 ) # Recommended for clarity. 2316 $termios->getattr() 2317 2318Obtain the attributes for stdout. 2319 2320 $termios->getattr( 1 ) 2321 2322Returns C<undef> on failure. 2323 2324=item C<getcc> 2325 2326Retrieve a value from the C<c_cc> field of a C<termios> object. The C<c_cc> field is 2327an array so an index must be specified. 2328 2329 $c_cc[1] = $termios->getcc(1); 2330 2331=item C<getcflag> 2332 2333Retrieve the C<c_cflag> field of a C<termios> object. 2334 2335 $c_cflag = $termios->getcflag; 2336 2337=item C<getiflag> 2338 2339Retrieve the C<c_iflag> field of a C<termios> object. 2340 2341 $c_iflag = $termios->getiflag; 2342 2343=item C<getispeed> 2344 2345Retrieve the input baud rate. 2346 2347 $ispeed = $termios->getispeed; 2348 2349=item C<getlflag> 2350 2351Retrieve the C<c_lflag> field of a C<termios> object. 2352 2353 $c_lflag = $termios->getlflag; 2354 2355=item C<getoflag> 2356 2357Retrieve the C<c_oflag> field of a C<termios> object. 2358 2359 $c_oflag = $termios->getoflag; 2360 2361=item C<getospeed> 2362 2363Retrieve the output baud rate. 2364 2365 $ospeed = $termios->getospeed; 2366 2367=item C<setattr> 2368 2369Set terminal control attributes. 2370 2371Set attributes immediately for stdout. 2372 2373 $termios->setattr( 1, &POSIX::TCSANOW ); 2374 2375Returns C<undef> on failure. 2376 2377=item C<setcc> 2378 2379Set a value in the C<c_cc> field of a C<termios> object. The C<c_cc> field is an 2380array so an index must be specified. 2381 2382 $termios->setcc( &POSIX::VEOF, 1 ); 2383 2384=item C<setcflag> 2385 2386Set the C<c_cflag> field of a C<termios> object. 2387 2388 $termios->setcflag( $c_cflag | &POSIX::CLOCAL ); 2389 2390=item C<setiflag> 2391 2392Set the C<c_iflag> field of a C<termios> object. 2393 2394 $termios->setiflag( $c_iflag | &POSIX::BRKINT ); 2395 2396=item C<setispeed> 2397 2398Set the input baud rate. 2399 2400 $termios->setispeed( &POSIX::B9600 ); 2401 2402Returns C<undef> on failure. 2403 2404=item C<setlflag> 2405 2406Set the C<c_lflag> field of a C<termios> object. 2407 2408 $termios->setlflag( $c_lflag | &POSIX::ECHO ); 2409 2410=item C<setoflag> 2411 2412Set the C<c_oflag> field of a C<termios> object. 2413 2414 $termios->setoflag( $c_oflag | &POSIX::OPOST ); 2415 2416=item C<setospeed> 2417 2418Set the output baud rate. 2419 2420 $termios->setospeed( &POSIX::B9600 ); 2421 2422Returns C<undef> on failure. 2423 2424=item Baud rate values 2425 2426C<B38400> C<B75> C<B200> C<B134> C<B300> C<B1800> C<B150> C<B0> C<B19200> C<B1200> C<B9600> C<B600> C<B4800> C<B50> C<B2400> C<B110> 2427 2428=item Terminal interface values 2429 2430C<TCSADRAIN> C<TCSANOW> C<TCOON> C<TCIOFLUSH> C<TCOFLUSH> C<TCION> C<TCIFLUSH> C<TCSAFLUSH> C<TCIOFF> C<TCOOFF> 2431 2432=item C<c_cc> field values 2433 2434C<VEOF> C<VEOL> C<VERASE> C<VINTR> C<VKILL> C<VQUIT> C<VSUSP> C<VSTART> C<VSTOP> C<VMIN> C<VTIME> C<NCCS> 2435 2436=item C<c_cflag> field values 2437 2438C<CLOCAL> C<CREAD> C<CSIZE> C<CS5> C<CS6> C<CS7> C<CS8> C<CSTOPB> C<HUPCL> C<PARENB> C<PARODD> 2439 2440=item C<c_iflag> field values 2441 2442C<BRKINT> C<ICRNL> C<IGNBRK> C<IGNCR> C<IGNPAR> C<INLCR> C<INPCK> C<ISTRIP> C<IXOFF> C<IXON> C<PARMRK> 2443 2444=item C<c_lflag> field values 2445 2446C<ECHO> C<ECHOE> C<ECHOK> C<ECHONL> C<ICANON> C<IEXTEN> C<ISIG> C<NOFLSH> C<TOSTOP> 2447 2448=item C<c_oflag> field values 2449 2450C<OPOST> 2451 2452=back 2453 2454=head1 PATHNAME CONSTANTS 2455 2456=over 8 2457 2458=item Constants 2459 2460C<_PC_CHOWN_RESTRICTED> C<_PC_LINK_MAX> C<_PC_MAX_CANON> C<_PC_MAX_INPUT> C<_PC_NAME_MAX> 2461C<_PC_NO_TRUNC> C<_PC_PATH_MAX> C<_PC_PIPE_BUF> C<_PC_VDISABLE> 2462 2463=back 2464 2465=head1 POSIX CONSTANTS 2466 2467=over 8 2468 2469=item Constants 2470 2471C<_POSIX_ARG_MAX> C<_POSIX_CHILD_MAX> C<_POSIX_CHOWN_RESTRICTED> C<_POSIX_JOB_CONTROL> 2472C<_POSIX_LINK_MAX> C<_POSIX_MAX_CANON> C<_POSIX_MAX_INPUT> C<_POSIX_NAME_MAX> 2473C<_POSIX_NGROUPS_MAX> C<_POSIX_NO_TRUNC> C<_POSIX_OPEN_MAX> C<_POSIX_PATH_MAX> 2474C<_POSIX_PIPE_BUF> C<_POSIX_SAVED_IDS> C<_POSIX_SSIZE_MAX> C<_POSIX_STREAM_MAX> 2475C<_POSIX_TZNAME_MAX> C<_POSIX_VDISABLE> C<_POSIX_VERSION> 2476 2477=back 2478 2479=head1 RESOURCE CONSTANTS 2480 2481Imported with the C<:sys_resource_h> tag. 2482 2483=over 8 2484 2485=item Constants 2486 2487C<PRIO_PROCESS> C<PRIO_PGRP> C<PRIO_USER> 2488 2489=back 2490 2491=head1 SYSTEM CONFIGURATION 2492 2493=over 8 2494 2495=item Constants 2496 2497C<_SC_ARG_MAX> C<_SC_CHILD_MAX> C<_SC_CLK_TCK> C<_SC_JOB_CONTROL> C<_SC_NGROUPS_MAX> 2498C<_SC_OPEN_MAX> C<_SC_PAGESIZE> C<_SC_SAVED_IDS> C<_SC_STREAM_MAX> C<_SC_TZNAME_MAX> 2499C<_SC_VERSION> 2500 2501=back 2502 2503=head1 ERRNO 2504 2505=over 8 2506 2507=item Constants 2508 2509C<E2BIG> C<EACCES> C<EADDRINUSE> C<EADDRNOTAVAIL> C<EAFNOSUPPORT> C<EAGAIN> C<EALREADY> C<EBADF> C<EBADMSG> 2510C<EBUSY> C<ECANCELED> C<ECHILD> C<ECONNABORTED> C<ECONNREFUSED> C<ECONNRESET> C<EDEADLK> C<EDESTADDRREQ> 2511C<EDOM> C<EDQUOT> C<EEXIST> C<EFAULT> C<EFBIG> C<EHOSTDOWN> C<EHOSTUNREACH> C<EIDRM> C<EILSEQ> C<EINPROGRESS> 2512C<EINTR> C<EINVAL> C<EIO> C<EISCONN> C<EISDIR> C<ELOOP> C<EMFILE> C<EMLINK> C<EMSGSIZE> C<ENAMETOOLONG> 2513C<ENETDOWN> C<ENETRESET> C<ENETUNREACH> C<ENFILE> C<ENOBUFS> C<ENODATA> C<ENODEV> C<ENOENT> C<ENOEXEC> 2514C<ENOLCK> C<ENOLINK> C<ENOMEM> C<ENOMSG> C<ENOPROTOOPT> C<ENOSPC> C<ENOSR> C<ENOSTR> C<ENOSYS> C<ENOTBLK> 2515C<ENOTCONN> C<ENOTDIR> C<ENOTEMPTY> C<ENOTRECOVERABLE> C<ENOTSOCK> C<ENOTSUP> C<ENOTTY> C<ENXIO> 2516C<EOPNOTSUPP> C<EOTHER> C<EOVERFLOW> C<EOWNERDEAD> C<EPERM> C<EPFNOSUPPORT> C<EPIPE> C<EPROCLIM> C<EPROTO> 2517C<EPROTONOSUPPORT> C<EPROTOTYPE> C<ERANGE> C<EREMOTE> C<ERESTART> C<EROFS> C<ESHUTDOWN> 2518C<ESOCKTNOSUPPORT> C<ESPIPE> C<ESRCH> C<ESTALE> C<ETIME> C<ETIMEDOUT> C<ETOOMANYREFS> C<ETXTBSY> C<EUSERS> 2519C<EWOULDBLOCK> C<EXDEV> 2520 2521=back 2522 2523=head1 FCNTL 2524 2525=over 8 2526 2527=item Constants 2528 2529C<FD_CLOEXEC> C<F_DUPFD> C<F_GETFD> C<F_GETFL> C<F_GETLK> C<F_OK> C<F_RDLCK> C<F_SETFD> C<F_SETFL> C<F_SETLK> 2530C<F_SETLKW> C<F_UNLCK> C<F_WRLCK> C<O_ACCMODE> C<O_APPEND> C<O_CREAT> C<O_EXCL> C<O_NOCTTY> C<O_NONBLOCK> 2531C<O_RDONLY> C<O_RDWR> C<O_TRUNC> C<O_WRONLY> 2532 2533=back 2534 2535=head1 FLOAT 2536 2537=over 8 2538 2539=item Constants 2540 2541C<DBL_DIG> C<DBL_EPSILON> C<DBL_MANT_DIG> C<DBL_MAX> C<DBL_MAX_10_EXP> C<DBL_MAX_EXP> C<DBL_MIN> 2542C<DBL_MIN_10_EXP> C<DBL_MIN_EXP> C<FLT_DIG> C<FLT_EPSILON> C<FLT_MANT_DIG> C<FLT_MAX> 2543C<FLT_MAX_10_EXP> C<FLT_MAX_EXP> C<FLT_MIN> C<FLT_MIN_10_EXP> C<FLT_MIN_EXP> C<FLT_RADIX> 2544C<FLT_ROUNDS> C<LDBL_DIG> C<LDBL_EPSILON> C<LDBL_MANT_DIG> C<LDBL_MAX> C<LDBL_MAX_10_EXP> 2545C<LDBL_MAX_EXP> C<LDBL_MIN> C<LDBL_MIN_10_EXP> C<LDBL_MIN_EXP> 2546 2547=back 2548 2549=head1 FLOATING-POINT ENVIRONMENT 2550 2551=over 8 2552 2553=item Constants 2554 2555C<FE_DOWNWARD> C<FE_TONEAREST> C<FE_TOWARDZERO> C<FE_UPWARD> 2556on systems that support them. 2557 2558=back 2559 2560=head1 LIMITS 2561 2562=over 8 2563 2564=item Constants 2565 2566C<ARG_MAX> C<CHAR_BIT> C<CHAR_MAX> C<CHAR_MIN> C<CHILD_MAX> C<INT_MAX> C<INT_MIN> C<LINK_MAX> C<LONG_MAX> 2567C<LONG_MIN> C<MAX_CANON> C<MAX_INPUT> C<MB_LEN_MAX> C<NAME_MAX> C<NGROUPS_MAX> C<OPEN_MAX> C<PATH_MAX> 2568C<PIPE_BUF> C<SCHAR_MAX> C<SCHAR_MIN> C<SHRT_MAX> C<SHRT_MIN> C<SSIZE_MAX> C<STREAM_MAX> C<TZNAME_MAX> 2569C<UCHAR_MAX> C<UINT_MAX> C<ULONG_MAX> C<USHRT_MAX> 2570 2571=back 2572 2573=head1 LOCALE 2574 2575=over 8 2576 2577=item Constants 2578 2579C<LC_ALL> C<LC_COLLATE> C<LC_CTYPE> C<LC_MONETARY> C<LC_NUMERIC> C<LC_TIME> C<LC_MESSAGES> 2580on systems that support them. 2581 2582=back 2583 2584=head1 MATH 2585 2586=over 8 2587 2588=item Constants 2589 2590C<HUGE_VAL> 2591 2592C<FP_ILOGB0> C<FP_ILOGBNAN> C<FP_INFINITE> C<FP_NAN> C<FP_NORMAL> C<FP_SUBNORMAL> C<FP_ZERO> 2593C<INFINITY> C<NAN> C<Inf> C<NaN> 2594C<M_1_PI> C<M_2_PI> C<M_2_SQRTPI> C<M_E> C<M_LN10> C<M_LN2> C<M_LOG10E> C<M_LOG2E> C<M_PI> 2595C<M_PI_2> C<M_PI_4> C<M_SQRT1_2> C<M_SQRT2> 2596on systems with C99 support. 2597 2598=back 2599 2600=head1 SIGNAL 2601 2602=over 8 2603 2604=item Constants 2605 2606C<SA_NOCLDSTOP> C<SA_NOCLDWAIT> C<SA_NODEFER> C<SA_ONSTACK> C<SA_RESETHAND> C<SA_RESTART> 2607C<SA_SIGINFO> C<SIGABRT> C<SIGALRM> C<SIGCHLD> C<SIGCONT> C<SIGFPE> C<SIGHUP> C<SIGILL> C<SIGINT> 2608C<SIGKILL> C<SIGPIPE> C<SIGQUIT> C<SIGSEGV> C<SIGSTOP> C<SIGTERM> C<SIGTSTP> C<SIGTTIN> C<SIGTTOU> 2609C<SIGUSR1> C<SIGUSR2> C<SIG_BLOCK> C<SIG_DFL> C<SIG_ERR> C<SIG_IGN> C<SIG_SETMASK> 2610C<SIG_UNBLOCK> 2611C<ILL_ILLOPC> C<ILL_ILLOPN> C<ILL_ILLADR> C<ILL_ILLTRP> C<ILL_PRVOPC> C<ILL_PRVREG> C<ILL_COPROC> 2612C<ILL_BADSTK> C<FPE_INTDIV> C<FPE_INTOVF> C<FPE_FLTDIV> C<FPE_FLTOVF> C<FPE_FLTUND> C<FPE_FLTRES> 2613C<FPE_FLTINV> C<FPE_FLTSUB> C<SEGV_MAPERR> C<SEGV_ACCERR> C<BUS_ADRALN> C<BUS_ADRERR> 2614C<BUS_OBJERR> C<TRAP_BRKPT> C<TRAP_TRACE> C<CLD_EXITED> C<CLD_KILLED> C<CLD_DUMPED> C<CLD_TRAPPED> 2615C<CLD_STOPPED> C<CLD_CONTINUED> C<POLL_IN> C<POLL_OUT> C<POLL_MSG> C<POLL_ERR> C<POLL_PRI> 2616C<POLL_HUP> C<SI_USER> C<SI_QUEUE> C<SI_TIMER> C<SI_ASYNCIO> C<SI_MESGQ> 2617 2618=back 2619 2620=head1 STAT 2621 2622=over 8 2623 2624=item Constants 2625 2626C<S_IRGRP> C<S_IROTH> C<S_IRUSR> C<S_IRWXG> C<S_IRWXO> C<S_IRWXU> C<S_ISGID> C<S_ISUID> C<S_IWGRP> C<S_IWOTH> 2627C<S_IWUSR> C<S_IXGRP> C<S_IXOTH> C<S_IXUSR> 2628 2629=item Macros 2630 2631C<S_ISBLK> C<S_ISCHR> C<S_ISDIR> C<S_ISFIFO> C<S_ISREG> 2632 2633=back 2634 2635=head1 STDLIB 2636 2637=over 8 2638 2639=item Constants 2640 2641C<EXIT_FAILURE> C<EXIT_SUCCESS> C<MB_CUR_MAX> C<RAND_MAX> 2642 2643=back 2644 2645=head1 STDIO 2646 2647=over 8 2648 2649=item Constants 2650 2651C<BUFSIZ> C<EOF> C<FILENAME_MAX> C<L_ctermid> C<L_cuserid> C<TMP_MAX> 2652 2653=back 2654 2655=head1 TIME 2656 2657=over 8 2658 2659=item Constants 2660 2661C<CLK_TCK> C<CLOCKS_PER_SEC> 2662 2663=back 2664 2665=head1 UNISTD 2666 2667=over 8 2668 2669=item Constants 2670 2671C<R_OK> C<SEEK_CUR> C<SEEK_END> C<SEEK_SET> C<STDIN_FILENO> C<STDOUT_FILENO> C<STDERR_FILENO> C<W_OK> C<X_OK> 2672 2673=back 2674 2675=head1 WAIT 2676 2677=over 8 2678 2679=item Constants 2680 2681C<WNOHANG> C<WUNTRACED> 2682 2683=over 16 2684 2685=item C<WNOHANG> 2686 2687Do not suspend the calling process until a child process 2688changes state but instead return immediately. 2689 2690=item C<WUNTRACED> 2691 2692Catch stopped child processes. 2693 2694=back 2695 2696=item Macros 2697 2698C<WIFEXITED> C<WEXITSTATUS> C<WIFSIGNALED> C<WTERMSIG> C<WIFSTOPPED> C<WSTOPSIG> 2699 2700=over 16 2701 2702=item C<WIFEXITED> 2703 2704C<WIFEXITED(${^CHILD_ERROR_NATIVE})> returns true if the child process 2705exited normally (C<exit()> or by falling off the end of C<main()>) 2706 2707=item C<WEXITSTATUS> 2708 2709C<WEXITSTATUS(${^CHILD_ERROR_NATIVE})> returns the normal exit status of 2710the child process (only meaningful if C<WIFEXITED(${^CHILD_ERROR_NATIVE})> 2711is true) 2712 2713=item C<WIFSIGNALED> 2714 2715C<WIFSIGNALED(${^CHILD_ERROR_NATIVE})> returns true if the child process 2716terminated because of a signal 2717 2718=item C<WTERMSIG> 2719 2720C<WTERMSIG(${^CHILD_ERROR_NATIVE})> returns the signal the child process 2721terminated for (only meaningful if 2722C<WIFSIGNALED(${^CHILD_ERROR_NATIVE})> 2723is true) 2724 2725=item C<WIFSTOPPED> 2726 2727C<WIFSTOPPED(${^CHILD_ERROR_NATIVE})> returns true if the child process is 2728currently stopped (can happen only if you specified the WUNTRACED flag 2729to C<waitpid()>) 2730 2731=item C<WSTOPSIG> 2732 2733C<WSTOPSIG(${^CHILD_ERROR_NATIVE})> returns the signal the child process 2734was stopped for (only meaningful if 2735C<WIFSTOPPED(${^CHILD_ERROR_NATIVE})> 2736is true) 2737 2738=back 2739 2740=back 2741 2742=head1 WINSOCK 2743 2744(Windows only.) 2745 2746=over 8 2747 2748=item Constants 2749 2750C<WSAEINTR> C<WSAEBADF> C<WSAEACCES> C<WSAEFAULT> C<WSAEINVAL> C<WSAEMFILE> C<WSAEWOULDBLOCK> 2751C<WSAEINPROGRESS> C<WSAEALREADY> C<WSAENOTSOCK> C<WSAEDESTADDRREQ> C<WSAEMSGSIZE> 2752C<WSAEPROTOTYPE> C<WSAENOPROTOOPT> C<WSAEPROTONOSUPPORT> C<WSAESOCKTNOSUPPORT> 2753C<WSAEOPNOTSUPP> C<WSAEPFNOSUPPORT> C<WSAEAFNOSUPPORT> C<WSAEADDRINUSE> 2754C<WSAEADDRNOTAVAIL> C<WSAENETDOWN> C<WSAENETUNREACH> C<WSAENETRESET> C<WSAECONNABORTED> 2755C<WSAECONNRESET> C<WSAENOBUFS> C<WSAEISCONN> C<WSAENOTCONN> C<WSAESHUTDOWN> 2756C<WSAETOOMANYREFS> C<WSAETIMEDOUT> C<WSAECONNREFUSED> C<WSAELOOP> C<WSAENAMETOOLONG> 2757C<WSAEHOSTDOWN> C<WSAEHOSTUNREACH> C<WSAENOTEMPTY> C<WSAEPROCLIM> C<WSAEUSERS> 2758C<WSAEDQUOT> C<WSAESTALE> C<WSAEREMOTE> C<WSAEDISCON> C<WSAENOMORE> C<WSAECANCELLED> 2759C<WSAEINVALIDPROCTABLE> C<WSAEINVALIDPROVIDER> C<WSAEPROVIDERFAILEDINIT> 2760C<WSAEREFUSED> 2761 2762=back 2763 2764