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