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