New Opcode extension subsumes Safe
[p5sagit/p5-mst-13.2.git] / ext / POSIX / POSIX.pod
CommitLineData
37120919 1=head1 NAME
2
3POSIX - Perl interface to IEEE Std 1003.1
4
cb1a09d0 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
37120919 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. Things which are C<#defines> in C, like EINTR or O_NDELAY, are
23automatically exported into your namespace. All functions are only exported
24if you ask for them explicitly. Most likely people will prefer to use the
25fully-qualified function names.
26
27This document gives a condensed list of the features available in the POSIX
28module. Consult your operating system's manpages for general information on
29most features. Consult L<perlfunc> for functions which are noted as being
30identical to Perl's builtin functions.
31
32The first section describes POSIX functions from the 1003.1 specification.
33The second section describes some classes for signal objects, TTY objects,
34and other miscellaneous objects. The remaining sections list various
35constants and macros in an organization which roughly follows IEEE Std
361003.1b-1993.
37
37120919 38=head1 NOTE
39
40The POSIX module is probably the most complex Perl module supplied with
41the standard distribution. It incorporates autoloading, namespace games,
42and dynamic loading of code that's in Perl, C, or both. It's a great
43source of wisdom.
44
45=head1 CAVEATS
46
47A few functions are not implemented because they are C specific. If you
48attempt to call these, they will print a message telling you that they
49aren't implemented, and suggest using the Perl equivalent should one
50exist. For example, trying to access the setjmp() call will elicit the
51message "setjmp() is C-specific: use eval {} instead".
52
53Furthermore, some evil vendors will claim 1003.1 compliance, but in fact
54are not so: they will not pass the PCTS (POSIX Compliance Test Suites).
55For example, one vendor may not define EDEADLK, or the semantics of the
56errno values set by open(2) might not be quite right. Perl does not
57attempt to verify POSIX compliance. That means you can currently
58successfully say "use POSIX", and then later in your program you find
59that your vendor has been lax and there's no usable ICANON macro after
60all. This could be construed to be a bug.
61
62=head1 FUNCTIONS
63
64=over 8
65
66=item _exit
67
68This is identical to the C function C<_exit()>.
69
70=item abort
71
72This is identical to the C function C<abort()>.
73
74=item abs
75
76This is identical to Perl's builtin C<abs()> function.
77
78=item access
79
80Determines the accessibility of a file.
81
82 if( POSIX::access( "/", &POSIX::R_OK ) ){
83 print "have read permission\n";
84 }
85
86Returns C<undef> on failure.
87
88=item acos
89
90This is identical to the C function C<acos()>.
91
92=item alarm
93
94This is identical to Perl's builtin C<alarm()> function.
95
96=item asctime
97
98This is identical to the C function C<asctime()>.
99
100=item asin
101
102This is identical to the C function C<asin()>.
103
104=item assert
105
cb1a09d0 106Unimplemented.
37120919 107
108=item atan
109
110This is identical to the C function C<atan()>.
111
112=item atan2
113
114This is identical to Perl's builtin C<atan2()> function.
115
116=item atexit
117
118atexit() is C-specific: use END {} instead.
119
120=item atof
121
122atof() is C-specific.
123
124=item atoi
125
126atoi() is C-specific.
127
128=item atol
129
130atol() is C-specific.
131
132=item bsearch
133
134bsearch() not supplied.
135
136=item calloc
137
138calloc() is C-specific.
139
140=item ceil
141
142This is identical to the C function C<ceil()>.
143
144=item chdir
145
146This is identical to Perl's builtin C<chdir()> function.
147
148=item chmod
149
150This is identical to Perl's builtin C<chmod()> function.
151
152=item chown
153
154This is identical to Perl's builtin C<chown()> function.
155
156=item clearerr
157
158Use method C<FileHandle::clearerr()> instead.
159
160=item clock
161
162This is identical to the C function C<clock()>.
163
164=item close
165
cb1a09d0 166Close the file. This uses file descriptors such as those obtained by calling
167C<POSIX::open>.
168
169 $fd = POSIX::open( "foo", &POSIX::O_RDONLY );
170 POSIX::close( $fd );
37120919 171
172Returns C<undef> on failure.
173
174=item closedir
175
176This is identical to Perl's builtin C<closedir()> function.
177
178=item cos
179
180This is identical to Perl's builtin C<cos()> function.
181
182=item cosh
183
184This is identical to the C function C<cosh()>.
185
186=item creat
187
cb1a09d0 188Create a new file. This returns a file descriptor like the ones returned by
189C<POSIX::open>. Use C<POSIX::close> to close the file.
190
191 $fd = POSIX::creat( "foo", 0611 );
192 POSIX::close( $fd );
37120919 193
194=item ctermid
195
cb1a09d0 196Generates the path name for the controlling terminal.
37120919 197
198 $path = POSIX::ctermid();
199
200=item ctime
201
202This is identical to the C function C<ctime()>.
203
204=item cuserid
205
206Get the character login name of the user.
207
208 $name = POSIX::cuserid();
209
210=item difftime
211
212This is identical to the C function C<difftime()>.
213
214=item div
215
216div() is C-specific.
217
218=item dup
219
cb1a09d0 220This is similar to the C function C<dup()>.
221
222This uses file descriptors such as those obtained by calling
223C<POSIX::open>.
37120919 224
225Returns C<undef> on failure.
226
227=item dup2
228
cb1a09d0 229This is similar to the C function C<dup2()>.
230
231This uses file descriptors such as those obtained by calling
232C<POSIX::open>.
37120919 233
234Returns C<undef> on failure.
235
236=item errno
237
238Returns the value of errno.
239
240 $errno = POSIX::errno();
241
242=item execl
243
244execl() is C-specific.
245
246=item execle
247
248execle() is C-specific.
249
250=item execlp
251
252execlp() is C-specific.
253
254=item execv
255
256execv() is C-specific.
257
258=item execve
259
260execve() is C-specific.
261
262=item execvp
263
264execvp() is C-specific.
265
266=item exit
267
268This is identical to Perl's builtin C<exit()> function.
269
270=item exp
271
272This is identical to Perl's builtin C<exp()> function.
273
274=item fabs
275
276This is identical to Perl's builtin C<abs()> function.
277
278=item fclose
279
280Use method C<FileHandle::close()> instead.
281
282=item fcntl
283
284This is identical to Perl's builtin C<fcntl()> function.
285
286=item fdopen
287
288Use method C<FileHandle::new_from_fd()> instead.
289
290=item feof
291
292Use method C<FileHandle::eof()> instead.
293
294=item ferror
295
296Use method C<FileHandle::error()> instead.
297
298=item fflush
299
300Use method C<FileHandle::flush()> instead.
301
302=item fgetc
303
304Use method C<FileHandle::getc()> instead.
305
306=item fgetpos
307
308Use method C<FileHandle::getpos()> instead.
309
310=item fgets
311
312Use method C<FileHandle::gets()> instead.
313
314=item fileno
315
316Use method C<FileHandle::fileno()> instead.
317
318=item floor
319
320This is identical to the C function C<floor()>.
321
322=item fmod
323
324This is identical to the C function C<fmod()>.
325
326=item fopen
327
328Use method C<FileHandle::open()> instead.
329
330=item fork
331
332This is identical to Perl's builtin C<fork()> function.
333
334=item fpathconf
335
cb1a09d0 336Retrieves the value of a configurable limit on a file or directory. This
337uses file descriptors such as those obtained by calling C<POSIX::open>.
338
339The following will determine the maximum length of the longest allowable
340pathname on the filesystem which holds C</tmp/foo>.
341
342 $fd = POSIX::open( "/tmp/foo", &POSIX::O_RDONLY );
343 $path_max = POSIX::fpathconf( $fd, &POSIX::_PC_PATH_MAX );
37120919 344
345Returns C<undef> on failure.
346
347=item fprintf
348
349fprintf() is C-specific--use printf instead.
350
351=item fputc
352
353fputc() is C-specific--use print instead.
354
355=item fputs
356
357fputs() is C-specific--use print instead.
358
359=item fread
360
361fread() is C-specific--use read instead.
362
363=item free
364
365free() is C-specific.
366
367=item freopen
368
369freopen() is C-specific--use open instead.
370
371=item frexp
372
cb1a09d0 373Return the mantissa and exponent of a floating-point number.
374
375 ($mantissa, $exponent) = POSIX::frexp( 3.14 );
37120919 376
377=item fscanf
378
379fscanf() is C-specific--use <> and regular expressions instead.
380
381=item fseek
382
383Use method C<FileHandle::seek()> instead.
384
385=item fsetpos
386
387Use method C<FileHandle::setpos()> instead.
388
389=item fstat
390
cb1a09d0 391Get file status. This uses file descriptors such as those obtained by
392calling C<POSIX::open>. The data returned is identical to the data from
393Perl's builtin C<stat> function.
394
395 $fd = POSIX::open( "foo", &POSIX::O_RDONLY );
396 @stats = POSIX::fstat( $fd );
37120919 397
398=item ftell
399
400Use method C<FileHandle::tell()> instead.
401
402=item fwrite
403
404fwrite() is C-specific--use print instead.
405
406=item getc
407
408This is identical to Perl's builtin C<getc()> function.
409
410=item getchar
411
412Returns one character from STDIN.
413
414=item getcwd
415
416Returns the name of the current working directory.
417
418=item getegid
419
420Returns the effective group id.
421
422=item getenv
423
424Returns the value of the specified enironment variable.
425
426=item geteuid
427
428Returns the effective user id.
429
430=item getgid
431
432Returns the user's real group id.
433
434=item getgrgid
435
436This is identical to Perl's builtin C<getgrgid()> function.
437
438=item getgrnam
439
440This is identical to Perl's builtin C<getgrnam()> function.
441
442=item getgroups
443
444Returns the ids of the user's supplementary groups.
445
446=item getlogin
447
448This is identical to Perl's builtin C<getlogin()> function.
449
450=item getpgrp
451
452This is identical to Perl's builtin C<getpgrp()> function.
453
454=item getpid
455
456Returns the process's id.
457
458=item getppid
459
460This is identical to Perl's builtin C<getppid()> function.
461
462=item getpwnam
463
464This is identical to Perl's builtin C<getpwnam()> function.
465
466=item getpwuid
467
468This is identical to Perl's builtin C<getpwuid()> function.
469
470=item gets
471
472Returns one line from STDIN.
473
474=item getuid
475
476Returns the user's id.
477
478=item gmtime
479
480This is identical to Perl's builtin C<gmtime()> function.
481
482=item isalnum
483
cb1a09d0 484This is identical to the C function, except that it can apply to a single
485character or to a whole string.
37120919 486
487=item isalpha
488
cb1a09d0 489This is identical to the C function, except that it can apply to a single
490character or to a whole string.
37120919 491
492=item isatty
493
494Returns a boolean indicating whether the specified filehandle is connected
495to a tty.
496
497=item iscntrl
498
cb1a09d0 499This is identical to the C function, except that it can apply to a single
500character or to a whole string.
37120919 501
502=item isdigit
503
cb1a09d0 504This is identical to the C function, except that it can apply to a single
505character or to a whole string.
37120919 506
507=item isgraph
508
cb1a09d0 509This is identical to the C function, except that it can apply to a single
510character or to a whole string.
37120919 511
512=item islower
513
cb1a09d0 514This is identical to the C function, except that it can apply to a single
515character or to a whole string.
37120919 516
517=item isprint
518
cb1a09d0 519This is identical to the C function, except that it can apply to a single
520character or to a whole string.
37120919 521
522=item ispunct
523
cb1a09d0 524This is identical to the C function, except that it can apply to a single
525character or to a whole string.
37120919 526
527=item isspace
528
cb1a09d0 529This is identical to the C function, except that it can apply to a single
530character or to a whole string.
37120919 531
532=item isupper
533
cb1a09d0 534This is identical to the C function, except that it can apply to a single
535character or to a whole string.
37120919 536
537=item isxdigit
538
cb1a09d0 539This is identical to the C function, except that it can apply to a single
540character or to a whole string.
37120919 541
542=item kill
543
544This is identical to Perl's builtin C<kill()> function.
545
546=item labs
547
548labs() is C-specific, use abs instead.
549
550=item ldexp
551
552This is identical to the C function C<ldexp()>.
553
554=item ldiv
555
556ldiv() is C-specific, use / and int instead.
557
558=item link
559
560This is identical to Perl's builtin C<link()> function.
561
562=item localeconv
563
cb1a09d0 564Get numeric formatting information. Returns a reference to a hash
565containing the current locale formatting values.
566
567The database for the B<de> (Deutsch or German) locale.
568
569 $loc = POSIX::setlocale( &POSIX::LC_ALL, "de" );
570 print "Locale = $loc\n";
571 $lconv = POSIX::localeconv();
572 print "decimal_point = ", $lconv->{decimal_point}, "\n";
573 print "thousands_sep = ", $lconv->{thousands_sep}, "\n";
574 print "grouping = ", $lconv->{grouping}, "\n";
575 print "int_curr_symbol = ", $lconv->{int_curr_symbol}, "\n";
576 print "currency_symbol = ", $lconv->{currency_symbol}, "\n";
577 print "mon_decimal_point = ", $lconv->{mon_decimal_point}, "\n";
578 print "mon_thousands_sep = ", $lconv->{mon_thousands_sep}, "\n";
579 print "mon_grouping = ", $lconv->{mon_grouping}, "\n";
580 print "positive_sign = ", $lconv->{positive_sign}, "\n";
581 print "negative_sign = ", $lconv->{negative_sign}, "\n";
582 print "int_frac_digits = ", $lconv->{int_frac_digits}, "\n";
583 print "frac_digits = ", $lconv->{frac_digits}, "\n";
584 print "p_cs_precedes = ", $lconv->{p_cs_precedes}, "\n";
585 print "p_sep_by_space = ", $lconv->{p_sep_by_space}, "\n";
586 print "n_cs_precedes = ", $lconv->{n_cs_precedes}, "\n";
587 print "n_sep_by_space = ", $lconv->{n_sep_by_space}, "\n";
588 print "p_sign_posn = ", $lconv->{p_sign_posn}, "\n";
589 print "n_sign_posn = ", $lconv->{n_sign_posn}, "\n";
37120919 590
591=item localtime
592
593This is identical to Perl's builtin C<localtime()> function.
594
595=item log
596
597This is identical to Perl's builtin C<log()> function.
598
599=item log10
600
601This is identical to the C function C<log10()>.
602
603=item longjmp
604
605longjmp() is C-specific: use die instead.
606
607=item lseek
608
cb1a09d0 609Move the read/write file pointer. This uses file descriptors such as
610those obtained by calling C<POSIX::open>.
611
612 $fd = POSIX::open( "foo", &POSIX::O_RDONLY );
613 $off_t = POSIX::lseek( $fd, 0, &POSIX::SEEK_SET );
37120919 614
615Returns C<undef> on failure.
616
617=item malloc
618
619malloc() is C-specific.
620
621=item mblen
622
cb1a09d0 623This is identical to the C function C<mblen()>.
37120919 624
625=item mbstowcs
626
cb1a09d0 627This is identical to the C function C<mbstowcs()>.
37120919 628
629=item mbtowc
630
cb1a09d0 631This is identical to the C function C<mbtowc()>.
37120919 632
633=item memchr
634
635memchr() is C-specific, use index() instead.
636
637=item memcmp
638
639memcmp() is C-specific, use eq instead.
640
641=item memcpy
642
643memcpy() is C-specific, use = instead.
644
645=item memmove
646
647memmove() is C-specific, use = instead.
648
649=item memset
650
651memset() is C-specific, use x instead.
652
653=item mkdir
654
655This is identical to Perl's builtin C<mkdir()> function.
656
657=item mkfifo
658
cb1a09d0 659This is similar to the C function C<mkfifo()>.
37120919 660
661Returns C<undef> on failure.
662
663=item mktime
664
cb1a09d0 665Convert date/time info to a calendar time.
666
667Synopsis:
668
669 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
670
671The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero.
672I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The
673year (C<year>) is given in years since 1900. I.e. The year 1995 is 95; the
674year 2001 is 101. Consult your system's C<mktime()> manpage for details
675about these and the other arguments.
676
677Calendar time for December 12, 1995, at 10:30 am.
678
679 $time_t = POSIX::mktime( 0, 30, 10, 12, 11, 95 );
680 print "Date = ", POSIX::ctime($time_t);
37120919 681
682Returns C<undef> on failure.
683
684=item modf
685
cb1a09d0 686Return the integral and fractional parts of a floating-point number.
687
688 ($fractional, $integral) = POSIX::modf( 3.14 );
37120919 689
690=item nice
691
cb1a09d0 692This is similar to the C function C<nice()>.
37120919 693
694Returns C<undef> on failure.
695
696=item offsetof
697
698offsetof() is C-specific.
699
700=item open
701
cb1a09d0 702Open a file for reading for writing. This returns file descriptors, not
703Perl filehandles. Use C<POSIX::close> to close the file.
704
705Open a file read-only with mode 0666.
706
707 $fd = POSIX::open( "foo" );
708
709Open a file for read and write.
710
711 $fd = POSIX::open( "foo", &POSIX::O_RDWR );
712
713Open a file for write, with truncation.
714
715 $fd = POSIX::open( "foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC );
716
717Create a new file with mode 0640. Set up the file for writing.
718
719 $fd = POSIX::open( "foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0640 );
37120919 720
721Returns C<undef> on failure.
722
723=item opendir
724
cb1a09d0 725Open a directory for reading.
726
727 $dir = POSIX::opendir( "/tmp" );
728 @files = POSIX::readdir( $dir );
729 POSIX::closedir( $dir );
730
731Returns C<undef> on failure.
37120919 732
733=item pathconf
734
735Retrieves the value of a configurable limit on a file or directory.
736
737The following will determine the maximum length of the longest allowable
738pathname on the filesystem which holds C</tmp>.
739
740 $path_max = POSIX::pathconf( "/tmp", &POSIX::_PC_PATH_MAX );
741
742Returns C<undef> on failure.
743
744=item pause
745
746This is similar to the C function C<pause()>.
747
748Returns C<undef> on failure.
749
750=item perror
751
752This is identical to the C function C<perror()>.
753
754=item pipe
755
cb1a09d0 756Create an interprocess channel. This returns file descriptors like those
757returned by C<POSIX::open>.
758
759 ($fd0, $fd1) = POSIX::pipe();
760 POSIX::write( $fd0, "hello", 5 );
761 POSIX::read( $fd1, $buf, 5 );
37120919 762
763=item pow
764
765Computes $x raised to the power $exponent.
766
767 $ret = POSIX::pow( $x, $exponent );
768
769=item printf
770
771Prints the specified arguments to STDOUT.
772
773=item putc
774
775putc() is C-specific--use print instead.
776
777=item putchar
778
779putchar() is C-specific--use print instead.
780
781=item puts
782
783puts() is C-specific--use print instead.
784
785=item qsort
786
787qsort() is C-specific, use sort instead.
788
789=item raise
790
791Sends the specified signal to the current process.
792
793=item rand
794
795rand() is non-portable, use Perl's rand instead.
796
797=item read
798
cb1a09d0 799Read from a file. This uses file descriptors such as those obtained by
800calling C<POSIX::open>. If the buffer C<$buf> is not large enough for the
801read then Perl will extend it to make room for the request.
802
803 $fd = POSIX::open( "foo", &POSIX::O_RDONLY );
804 $bytes = POSIX::read( $fd, $buf, 3 );
37120919 805
806Returns C<undef> on failure.
807
808=item readdir
809
810This is identical to Perl's builtin C<readdir()> function.
811
812=item realloc
813
814realloc() is C-specific.
815
816=item remove
817
818This is identical to Perl's builtin C<unlink()> function.
819
820=item rename
821
822This is identical to Perl's builtin C<rename()> function.
823
824=item rewind
825
826Seeks to the beginning of the file.
827
828=item rewinddir
829
830This is identical to Perl's builtin C<rewinddir()> function.
831
832=item rmdir
833
834This is identical to Perl's builtin C<rmdir()> function.
835
836=item scanf
837
838scanf() is C-specific--use <> and regular expressions instead.
839
840=item setgid
841
842Sets the real group id for this process.
843
844=item setjmp
845
846setjmp() is C-specific: use eval {} instead.
847
848=item setlocale
849
850Modifies and queries program's locale.
851
852The following will set the traditional UNIX system locale behavior.
853
854 $loc = POSIX::setlocale( &POSIX::LC_ALL, "C" );
855
856=item setpgid
857
cb1a09d0 858This is similar to the C function C<setpgid()>.
37120919 859
860Returns C<undef> on failure.
861
862=item setsid
863
864This is identical to the C function C<setsid()>.
865
866=item setuid
867
868Sets the real user id for this process.
869
870=item sigaction
871
cb1a09d0 872Detailed signal management. This uses C<POSIX::SigAction> objects for the
873C<action> and C<oldaction> arguments. Consult your system's C<sigaction>
874manpage for details.
875
876Synopsis:
877
878 sigaction(sig, action, oldaction = 0)
37120919 879
880Returns C<undef> on failure.
881
882=item siglongjmp
883
884siglongjmp() is C-specific: use die instead.
885
886=item sigpending
887
cb1a09d0 888Examine signals that are blocked and pending. This uses C<POSIX::SigSet>
889objects for the C<sigset> argument. Consult your system's C<sigpending>
890manpage for details.
891
892Synopsis:
893
894 sigpending(sigset)
37120919 895
896Returns C<undef> on failure.
897
898=item sigprocmask
899
cb1a09d0 900Change and/or examine calling process's signal mask. This uses
901C<POSIX::SigSet> objects for the C<sigset> and C<oldsigset> arguments.
902Consult your system's C<sigprocmask> manpage for details.
903
904Synopsis:
905
906 sigprocmask(how, sigset, oldsigset = 0)
37120919 907
908Returns C<undef> on failure.
909
910=item sigsetjmp
911
912sigsetjmp() is C-specific: use eval {} instead.
913
914=item sigsuspend
915
cb1a09d0 916Install a signal mask and suspend process until signal arrives. This uses
917C<POSIX::SigSet> objects for the C<signal_mask> argument. Consult your
918system's C<sigsuspend> manpage for details.
919
920Synopsis:
921
922 sigsuspend(signal_mask)
37120919 923
924Returns C<undef> on failure.
925
926=item sin
927
928This is identical to Perl's builtin C<sin()> function.
929
930=item sinh
931
932This is identical to the C function C<sinh()>.
933
934=item sleep
935
936This is identical to Perl's builtin C<sleep()> function.
937
938=item sprintf
939
cb1a09d0 940This is identical to Perl's builtin C<sprintf()> function.
37120919 941
942=item sqrt
943
944This is identical to Perl's builtin C<sqrt()> function.
945
946=item srand
947
948srand().
949
950=item sscanf
951
952sscanf() is C-specific--use regular expressions instead.
953
954=item stat
955
956This is identical to Perl's builtin C<stat()> function.
957
958=item strcat
959
960strcat() is C-specific, use .= instead.
961
962=item strchr
963
964strchr() is C-specific, use index() instead.
965
966=item strcmp
967
968strcmp() is C-specific, use eq instead.
969
970=item strcoll
971
972This is identical to the C function C<strcoll()>.
973
974=item strcpy
975
976strcpy() is C-specific, use = instead.
977
978=item strcspn
979
980strcspn() is C-specific, use regular expressions instead.
981
982=item strerror
983
984Returns the error string for the specified errno.
985
986=item strftime
987
cb1a09d0 988Convert date and time information to string. Returns the string.
989
990Synopsis:
991
992 strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
993
994The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero.
995I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The
996year (C<year>) is given in years since 1900. I.e. The year 1995 is 95; the
997year 2001 is 101. Consult your system's C<strftime()> manpage for details
998about these and the other arguments.
999
1000The string for Tuesday, December 12, 1995.
1001
1002 $str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 );
1003 print "$str\n";
37120919 1004
1005=item strlen
1006
1007strlen() is C-specific, use length instead.
1008
1009=item strncat
1010
1011strncat() is C-specific, use .= instead.
1012
1013=item strncmp
1014
1015strncmp() is C-specific, use eq instead.
1016
1017=item strncpy
1018
1019strncpy() is C-specific, use = instead.
1020
1021=item stroul
1022
1023stroul() is C-specific.
1024
1025=item strpbrk
1026
1027strpbrk() is C-specific.
1028
1029=item strrchr
1030
1031strrchr() is C-specific, use rindex() instead.
1032
1033=item strspn
1034
1035strspn() is C-specific.
1036
1037=item strstr
1038
1039This is identical to Perl's builtin C<index()> function.
1040
1041=item strtod
1042
1043strtod() is C-specific.
1044
1045=item strtok
1046
1047strtok() is C-specific.
1048
1049=item strtol
1050
1051strtol() is C-specific.
1052
1053=item strxfrm
1054
cb1a09d0 1055String transformation. Returns the transformed string.
1056
1057 $dst = POSIX::strxfrm( $src );
37120919 1058
1059=item sysconf
1060
1061Retrieves values of system configurable variables.
1062
1063The following will get the machine's clock speed.
1064
1065 $clock_ticks = POSIX::sysconf( &POSIX::_SC_CLK_TCK );
1066
1067Returns C<undef> on failure.
1068
1069=item system
1070
1071This is identical to Perl's builtin C<system()> function.
1072
1073=item tan
1074
1075This is identical to the C function C<tan()>.
1076
1077=item tanh
1078
1079This is identical to the C function C<tanh()>.
1080
1081=item tcdrain
1082
cb1a09d0 1083This is similar to the C function C<tcdrain()>.
37120919 1084
1085Returns C<undef> on failure.
1086
1087=item tcflow
1088
cb1a09d0 1089This is similar to the C function C<tcflow()>.
37120919 1090
1091Returns C<undef> on failure.
1092
1093=item tcflush
1094
cb1a09d0 1095This is similar to the C function C<tcflush()>.
37120919 1096
1097Returns C<undef> on failure.
1098
1099=item tcgetpgrp
1100
1101This is identical to the C function C<tcgetpgrp()>.
1102
1103=item tcsendbreak
1104
cb1a09d0 1105This is similar to the C function C<tcsendbreak()>.
37120919 1106
1107Returns C<undef> on failure.
1108
1109=item tcsetpgrp
1110
cb1a09d0 1111This is similar to the C function C<tcsetpgrp()>.
37120919 1112
1113Returns C<undef> on failure.
1114
1115=item time
1116
1117This is identical to Perl's builtin C<time()> function.
1118
1119=item times
1120
1121The times() function returns elapsed realtime since some point in the past
1122(such as system startup), user and system times for this process, and user
1123and system times used by child processes. All times are returned in clock
1124ticks.
1125
1126 ($realtime, $user, $system, $cuser, $csystem) = POSIX::times();
1127
1128Note: Perl's builtin C<times()> function returns four values, measured in
1129seconds.
1130
1131=item tmpfile
1132
1133Use method C<FileHandle::new_tmpfile()> instead.
1134
1135=item tmpnam
1136
1137Returns a name for a temporary file.
1138
1139 $tmpfile = POSIX::tmpnam();
1140
1141=item tolower
1142
1143This is identical to Perl's builtin C<lc()> function.
1144
1145=item toupper
1146
1147This is identical to Perl's builtin C<uc()> function.
1148
1149=item ttyname
1150
cb1a09d0 1151This is identical to the C function C<ttyname()>.
37120919 1152
1153=item tzname
1154
cb1a09d0 1155Retrieves the time conversion information from the C<tzname> variable.
1156
1157 POSIX::tzset();
1158 ($std, $dst) = POSIX::tzname();
37120919 1159
1160=item tzset
1161
1162This is identical to the C function C<tzset()>.
1163
1164=item umask
1165
1166This is identical to Perl's builtin C<umask()> function.
1167
1168=item uname
1169
cb1a09d0 1170Get name of current operating system.
1171
1172 ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
37120919 1173
1174=item ungetc
1175
1176Use method C<FileHandle::ungetc()> instead.
1177
1178=item unlink
1179
1180This is identical to Perl's builtin C<unlink()> function.
1181
1182=item utime
1183
1184This is identical to Perl's builtin C<utime()> function.
1185
1186=item vfprintf
1187
1188vfprintf() is C-specific.
1189
1190=item vprintf
1191
1192vprintf() is C-specific.
1193
1194=item vsprintf
1195
1196vsprintf() is C-specific.
1197
1198=item wait
1199
cb1a09d0 1200This is identical to Perl's builtin C<wait()> function.
37120919 1201
1202=item waitpid
1203
cb1a09d0 1204Wait for a child process to change state. This is identical to Perl's
1205builtin C<waitpid()> function.
1206
1207 $pid = POSIX::waitpid( -1, &POSIX::WNOHANG );
1208 print "status = ", ($? / 256), "\n";
37120919 1209
1210=item wcstombs
1211
cb1a09d0 1212This is identical to the C function C<wcstombs()>.
37120919 1213
1214=item wctomb
1215
cb1a09d0 1216This is identical to the C function C<wctomb()>.
37120919 1217
1218=item write
1219
cb1a09d0 1220Write to a file. This uses file descriptors such as those obtained by
1221calling C<POSIX::open>.
1222
1223 $fd = POSIX::open( "foo", &POSIX::O_WRONLY );
1224 $buf = "hello";
1225 $bytes = POSIX::write( $b, $buf, 5 );
37120919 1226
1227Returns C<undef> on failure.
1228
1229=back
1230
1231=head1 CLASSES
1232
37120919 1233=head2 POSIX::SigAction
1234
1235=over 8
1236
1237=item new
1238
cb1a09d0 1239Creates a new C<POSIX::SigAction> object which corresponds to the C
1240C<struct sigaction>. This object will be destroyed automatically when it is
1241no longer needed. The first parameter is the fully-qualified name of a sub
1242which is a signal-handler. The second parameter is a C<POSIX::SigSet>
1243object. The third parameter contains the C<sa_flags>.
1244
1245 $sigset = POSIX::SigSet->new;
1246 $sigaction = POSIX::SigAction->new( 'main::handler', $sigset, &POSIX::SA_NOCLDSTOP );
1247
1248This C<POSIX::SigAction> object should be used with the C<POSIX::sigaction()>
1249function.
37120919 1250
1251=back
1252
1253=head2 POSIX::SigSet
1254
1255=over 8
1256
1257=item new
1258
1259Create a new SigSet object. This object will be destroyed automatically
1260when it is no longer needed. Arguments may be supplied to initialize the
1261set.
1262
1263Create an empty set.
1264
1265 $sigset = POSIX::SigSet->new;
1266
1267Create a set with SIGUSR1.
1268
1269 $sigset = POSIX::SigSet->new( &POSIX::SIGUSR1 );
1270
1271=item addset
1272
1273Add a signal to a SigSet object.
1274
1275 $sigset->addset( &POSIX::SIGUSR2 );
1276
1277Returns C<undef> on failure.
1278
1279=item delset
1280
1281Remove a signal from the SigSet object.
1282
1283 $sigset->delset( &POSIX::SIGUSR2 );
1284
1285Returns C<undef> on failure.
1286
1287=item emptyset
1288
1289Initialize the SigSet object to be empty.
1290
1291 $sigset->emptyset();
1292
1293Returns C<undef> on failure.
1294
1295=item fillset
1296
1297Initialize the SigSet object to include all signals.
1298
1299 $sigset->fillset();
1300
1301Returns C<undef> on failure.
1302
1303=item ismember
1304
1305Tests the SigSet object to see if it contains a specific signal.
1306
1307 if( $sigset->ismember( &POSIX::SIGUSR1 ) ){
1308 print "contains SIGUSR1\n";
1309 }
1310
1311=back
1312
1313=head2 POSIX::Termios
1314
1315=over 8
1316
1317=item new
1318
1319Create a new Termios object. This object will be destroyed automatically
1320when it is no longer needed.
1321
1322 $termios = POSIX::Termios->new;
1323
1324=item getattr
1325
cb1a09d0 1326Get terminal control attributes.
1327
1328Obtain the attributes for stdin.
1329
1330 $termios->getattr()
1331
1332Obtain the attributes for stdout.
1333
1334 $termios->getattr( 1 )
37120919 1335
1336Returns C<undef> on failure.
1337
1338=item getcc
1339
1340Retrieve a value from the c_cc field of a termios object. The c_cc field is
1341an array so an index must be specified.
1342
1343 $c_cc[1] = $termios->getcc(1);
1344
1345=item getcflag
1346
1347Retrieve the c_cflag field of a termios object.
1348
1349 $c_cflag = $termios->getcflag;
1350
1351=item getiflag
1352
1353Retrieve the c_iflag field of a termios object.
1354
1355 $c_iflag = $termios->getiflag;
1356
1357=item getispeed
1358
1359Retrieve the input baud rate.
1360
1361 $ispeed = $termios->getispeed;
1362
1363=item getlflag
1364
1365Retrieve the c_lflag field of a termios object.
1366
1367 $c_lflag = $termios->getlflag;
1368
1369=item getoflag
1370
1371Retrieve the c_oflag field of a termios object.
1372
1373 $c_oflag = $termios->getoflag;
1374
1375=item getospeed
1376
1377Retrieve the output baud rate.
1378
1379 $ospeed = $termios->getospeed;
1380
1381=item setattr
1382
cb1a09d0 1383Set terminal control attributes.
1384
1385Set attributes immediately for stdout.
1386
1387 $termios->setattr( 1, &POSIX::TCSANOW );
37120919 1388
1389Returns C<undef> on failure.
1390
1391=item setcc
1392
1393Set a value in the c_cc field of a termios object. The c_cc field is an
1394array so an index must be specified.
1395
1396 $termios->setcc( 1, &POSIX::VEOF );
1397
1398=item setcflag
1399
1400Set the c_cflag field of a termios object.
1401
1402 $termios->setcflag( &POSIX::CLOCAL );
1403
1404=item setiflag
1405
1406Set the c_iflag field of a termios object.
1407
1408 $termios->setiflag( &POSIX::BRKINT );
1409
1410=item setispeed
1411
1412Set the input baud rate.
1413
1414 $termios->setispeed( &POSIX::B9600 );
1415
1416Returns C<undef> on failure.
1417
1418=item setlflag
1419
1420Set the c_lflag field of a termios object.
1421
1422 $termios->setlflag( &POSIX::ECHO );
1423
1424=item setoflag
1425
1426Set the c_oflag field of a termios object.
1427
1428 $termios->setoflag( &POSIX::OPOST );
1429
1430=item setospeed
1431
1432Set the output baud rate.
1433
1434 $termios->setospeed( &POSIX::B9600 );
1435
1436Returns C<undef> on failure.
1437
1438=item Baud rate values
1439
1440B38400 B75 B200 B134 B300 B1800 B150 B0 B19200 B1200 B9600 B600 B4800 B50 B2400 B110
1441
1442=item Terminal interface values
1443
1444TCSADRAIN TCSANOW TCOON TCIOFLUSH TCOFLUSH TCION TCIFLUSH TCSAFLUSH TCIOFF TCOOFF
1445
1446=item c_cc field values
1447
1448VEOF VEOL VERASE VINTR VKILL VQUIT VSUSP VSTART VSTOP VMIN VTIME NCCS
1449
1450=item c_cflag field values
1451
1452CLOCAL CREAD CSIZE CS5 CS6 CS7 CS8 CSTOPB HUPCL PARENB PARODD
1453
1454=item c_iflag field values
1455
1456BRKINT ICRNL IGNBRK IGNCR IGNPAR INLCR INPCK ISTRIP IXOFF IXON PARMRK
1457
1458=item c_lflag field values
1459
1460ECHO ECHOE ECHOK ECHONL ICANON IEXTEN ISIG NOFLSH TOSTOP
1461
1462=item c_oflag field values
1463
1464OPOST
1465
1466=back
1467
1468=head1 PATHNAME CONSTANTS
1469
1470=over 8
1471
1472=item Constants
1473
1474_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
1475
1476=back
1477
1478=head1 POSIX CONSTANTS
1479
1480=over 8
1481
1482=item Constants
1483
1484_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
1485
1486=back
1487
1488=head1 SYSTEM CONFIGURATION
1489
1490=over 8
1491
1492=item Constants
1493
1494_SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_SAVED_IDS _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
1495
1496=back
1497
1498=head1 ERRNO
1499
1500=over 8
1501
1502=item Constants
1503
1504E2BIG EACCES EAGAIN EBADF EBUSY ECHILD EDEADLK EDOM EEXIST EFAULT EFBIG EINTR EINVAL EIO EISDIR EMFILE EMLINK ENAMETOOLONG ENFILE ENODEV ENOENT ENOEXEC ENOLCK ENOMEM ENOSPC ENOSYS ENOTDIR ENOTEMPTY ENOTTY ENXIO EPERM EPIPE ERANGE EROFS ESPIPE ESRCH EXDEV
1505
1506=back
1507
1508=head1 FCNTL
1509
1510=over 8
1511
1512=item Constants
1513
1514FD_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
1515
1516=back
1517
1518=head1 FLOAT
1519
1520=over 8
1521
1522=item Constants
1523
1524DBL_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
1525
1526=back
1527
1528=head1 LIMITS
1529
1530=over 8
1531
1532=item Constants
1533
1534ARG_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
1535
1536=back
1537
1538=head1 LOCALE
1539
1540=over 8
1541
1542=item Constants
1543
1544LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME
1545
1546=back
1547
1548=head1 MATH
1549
1550=over 8
1551
1552=item Constants
1553
1554HUGE_VAL
1555
1556=back
1557
1558=head1 SIGNAL
1559
1560=over 8
1561
1562=item Constants
1563
1564SA_NOCLDSTOP SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 SIG_BLOCK SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK SIG_UNBLOCK
1565
1566=back
1567
1568=head1 STAT
1569
1570=over 8
1571
1572=item Constants
1573
1574S_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
1575
1576=item Macros
1577
1578S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG
1579
1580=back
1581
1582=head1 STDLIB
1583
1584=over 8
1585
1586=item Constants
1587
1588EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX RAND_MAX
1589
1590=back
1591
1592=head1 STDIO
1593
1594=over 8
1595
1596=item Constants
1597
c07a80fd 1598BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid L_tmpname TMP_MAX
37120919 1599
1600=back
1601
1602=head1 TIME
1603
1604=over 8
1605
1606=item Constants
1607
1608CLK_TCK CLOCKS_PER_SEC
1609
1610=back
1611
1612=head1 UNISTD
1613
1614=over 8
1615
1616=item Constants
1617
1618R_OK SEEK_CUR SEEK_END SEEK_SET STDIN_FILENO STDOUT_FILENO STRERR_FILENO W_OK X_OK
1619
1620=back
1621
1622=head1 WAIT
1623
1624=over 8
1625
1626=item Constants
1627
1628WNOHANG WUNTRACED
1629
1630=item Macros
1631
1632WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG
1633
1634=back
1635
1636=head1 CREATION
1637
c07a80fd 1638This document generated by ./mkposixman.PL version 19960129.
37120919 1639