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