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