Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1730 lines
35 KiB

  1. =head1 NAME
  2. POSIX - Perl interface to IEEE Std 1003.1
  3. =head1 SYNOPSIS
  4. use POSIX;
  5. use POSIX qw(setsid);
  6. use POSIX qw(:errno_h :fcntl_h);
  7. printf "EINTR is %d\n", EINTR;
  8. $sess_id = POSIX::setsid();
  9. $fd = POSIX::open($path, O_CREAT|O_EXCL|O_WRONLY, 0644);
  10. # note: that's a filedescriptor, *NOT* a filehandle
  11. =head1 DESCRIPTION
  12. The POSIX module permits you to access all (or nearly all) the standard
  13. POSIX 1003.1 identifiers. Many of these identifiers have been given Perl-ish
  14. interfaces. Things which are C<#defines> in C, like EINTR or O_NDELAY, are
  15. automatically exported into your namespace. All functions are only exported
  16. if you ask for them explicitly. Most likely people will prefer to use the
  17. fully-qualified function names.
  18. This document gives a condensed list of the features available in the POSIX
  19. module. Consult your operating system's manpages for general information on
  20. most features. Consult L<perlfunc> for functions which are noted as being
  21. identical to Perl's builtin functions.
  22. The first section describes POSIX functions from the 1003.1 specification.
  23. The second section describes some classes for signal objects, TTY objects,
  24. and other miscellaneous objects. The remaining sections list various
  25. constants and macros in an organization which roughly follows IEEE Std
  26. 1003.1b-1993.
  27. =head1 NOTE
  28. The POSIX module is probably the most complex Perl module supplied with
  29. the standard distribution. It incorporates autoloading, namespace games,
  30. and dynamic loading of code that's in Perl, C, or both. It's a great
  31. source of wisdom.
  32. =head1 CAVEATS
  33. A few functions are not implemented because they are C specific. If you
  34. attempt to call these, they will print a message telling you that they
  35. aren't implemented, and suggest using the Perl equivalent should one
  36. exist. For example, trying to access the setjmp() call will elicit the
  37. message "setjmp() is C-specific: use eval {} instead".
  38. Furthermore, some evil vendors will claim 1003.1 compliance, but in fact
  39. are not so: they will not pass the PCTS (POSIX Compliance Test Suites).
  40. For example, one vendor may not define EDEADLK, or the semantics of the
  41. errno values set by open(2) might not be quite right. Perl does not
  42. attempt to verify POSIX compliance. That means you can currently
  43. successfully say "use POSIX", and then later in your program you find
  44. that your vendor has been lax and there's no usable ICANON macro after
  45. all. This could be construed to be a bug.
  46. =head1 FUNCTIONS
  47. =over 8
  48. =item _exit
  49. This is identical to the C function C<_exit()>.
  50. =item abort
  51. This is identical to the C function C<abort()>.
  52. =item abs
  53. This is identical to Perl's builtin C<abs()> function.
  54. =item access
  55. Determines the accessibility of a file.
  56. if( POSIX::access( "/", &POSIX::R_OK ) ){
  57. print "have read permission\n";
  58. }
  59. Returns C<undef> on failure.
  60. =item acos
  61. This is identical to the C function C<acos()>.
  62. =item alarm
  63. This is identical to Perl's builtin C<alarm()> function.
  64. =item asctime
  65. This is identical to the C function C<asctime()>.
  66. =item asin
  67. This is identical to the C function C<asin()>.
  68. =item assert
  69. Unimplemented.
  70. =item atan
  71. This is identical to the C function C<atan()>.
  72. =item atan2
  73. This is identical to Perl's builtin C<atan2()> function.
  74. =item atexit
  75. atexit() is C-specific: use END {} instead.
  76. =item atof
  77. atof() is C-specific.
  78. =item atoi
  79. atoi() is C-specific.
  80. =item atol
  81. atol() is C-specific.
  82. =item bsearch
  83. bsearch() not supplied.
  84. =item calloc
  85. calloc() is C-specific.
  86. =item ceil
  87. This is identical to the C function C<ceil()>.
  88. =item chdir
  89. This is identical to Perl's builtin C<chdir()> function.
  90. =item chmod
  91. This is identical to Perl's builtin C<chmod()> function.
  92. =item chown
  93. This is identical to Perl's builtin C<chown()> function.
  94. =item clearerr
  95. Use method C<IO::Handle::clearerr()> instead.
  96. =item clock
  97. This is identical to the C function C<clock()>.
  98. =item close
  99. Close the file. This uses file descriptors such as those obtained by calling
  100. C<POSIX::open>.
  101. $fd = POSIX::open( "foo", &POSIX::O_RDONLY );
  102. POSIX::close( $fd );
  103. Returns C<undef> on failure.
  104. =item closedir
  105. This is identical to Perl's builtin C<closedir()> function.
  106. =item cos
  107. This is identical to Perl's builtin C<cos()> function.
  108. =item cosh
  109. This is identical to the C function C<cosh()>.
  110. =item creat
  111. Create a new file. This returns a file descriptor like the ones returned by
  112. C<POSIX::open>. Use C<POSIX::close> to close the file.
  113. $fd = POSIX::creat( "foo", 0611 );
  114. POSIX::close( $fd );
  115. =item ctermid
  116. Generates the path name for the controlling terminal.
  117. $path = POSIX::ctermid();
  118. =item ctime
  119. This is identical to the C function C<ctime()>.
  120. =item cuserid
  121. Get the character login name of the user.
  122. $name = POSIX::cuserid();
  123. =item difftime
  124. This is identical to the C function C<difftime()>.
  125. =item div
  126. div() is C-specific.
  127. =item dup
  128. This is similar to the C function C<dup()>.
  129. This uses file descriptors such as those obtained by calling
  130. C<POSIX::open>.
  131. Returns C<undef> on failure.
  132. =item dup2
  133. This is similar to the C function C<dup2()>.
  134. This uses file descriptors such as those obtained by calling
  135. C<POSIX::open>.
  136. Returns C<undef> on failure.
  137. =item errno
  138. Returns the value of errno.
  139. $errno = POSIX::errno();
  140. =item execl
  141. execl() is C-specific.
  142. =item execle
  143. execle() is C-specific.
  144. =item execlp
  145. execlp() is C-specific.
  146. =item execv
  147. execv() is C-specific.
  148. =item execve
  149. execve() is C-specific.
  150. =item execvp
  151. execvp() is C-specific.
  152. =item exit
  153. This is identical to Perl's builtin C<exit()> function.
  154. =item exp
  155. This is identical to Perl's builtin C<exp()> function.
  156. =item fabs
  157. This is identical to Perl's builtin C<abs()> function.
  158. =item fclose
  159. Use method C<IO::Handle::close()> instead.
  160. =item fcntl
  161. This is identical to Perl's builtin C<fcntl()> function.
  162. =item fdopen
  163. Use method C<IO::Handle::new_from_fd()> instead.
  164. =item feof
  165. Use method C<IO::Handle::eof()> instead.
  166. =item ferror
  167. Use method C<IO::Handle::error()> instead.
  168. =item fflush
  169. Use method C<IO::Handle::flush()> instead.
  170. =item fgetc
  171. Use method C<IO::Handle::getc()> instead.
  172. =item fgetpos
  173. Use method C<IO::Seekable::getpos()> instead.
  174. =item fgets
  175. Use method C<IO::Handle::gets()> instead.
  176. =item fileno
  177. Use method C<IO::Handle::fileno()> instead.
  178. =item floor
  179. This is identical to the C function C<floor()>.
  180. =item fmod
  181. This is identical to the C function C<fmod()>.
  182. =item fopen
  183. Use method C<IO::File::open()> instead.
  184. =item fork
  185. This is identical to Perl's builtin C<fork()> function.
  186. =item fpathconf
  187. Retrieves the value of a configurable limit on a file or directory. This
  188. uses file descriptors such as those obtained by calling C<POSIX::open>.
  189. The following will determine the maximum length of the longest allowable
  190. pathname on the filesystem which holds C</tmp/foo>.
  191. $fd = POSIX::open( "/tmp/foo", &POSIX::O_RDONLY );
  192. $path_max = POSIX::fpathconf( $fd, &POSIX::_PC_PATH_MAX );
  193. Returns C<undef> on failure.
  194. =item fprintf
  195. fprintf() is C-specific--use printf instead.
  196. =item fputc
  197. fputc() is C-specific--use print instead.
  198. =item fputs
  199. fputs() is C-specific--use print instead.
  200. =item fread
  201. fread() is C-specific--use read instead.
  202. =item free
  203. free() is C-specific.
  204. =item freopen
  205. freopen() is C-specific--use open instead.
  206. =item frexp
  207. Return the mantissa and exponent of a floating-point number.
  208. ($mantissa, $exponent) = POSIX::frexp( 3.14 );
  209. =item fscanf
  210. fscanf() is C-specific--use <> and regular expressions instead.
  211. =item fseek
  212. Use method C<IO::Seekable::seek()> instead.
  213. =item fsetpos
  214. Use method C<IO::Seekable::setpos()> instead.
  215. =item fstat
  216. Get file status. This uses file descriptors such as those obtained by
  217. calling C<POSIX::open>. The data returned is identical to the data from
  218. Perl's builtin C<stat> function.
  219. $fd = POSIX::open( "foo", &POSIX::O_RDONLY );
  220. @stats = POSIX::fstat( $fd );
  221. =item ftell
  222. Use method C<IO::Seekable::tell()> instead.
  223. =item fwrite
  224. fwrite() is C-specific--use print instead.
  225. =item getc
  226. This is identical to Perl's builtin C<getc()> function.
  227. =item getchar
  228. Returns one character from STDIN.
  229. =item getcwd
  230. Returns the name of the current working directory.
  231. =item getegid
  232. Returns the effective group id.
  233. =item getenv
  234. Returns the value of the specified enironment variable.
  235. =item geteuid
  236. Returns the effective user id.
  237. =item getgid
  238. Returns the user's real group id.
  239. =item getgrgid
  240. This is identical to Perl's builtin C<getgrgid()> function.
  241. =item getgrnam
  242. This is identical to Perl's builtin C<getgrnam()> function.
  243. =item getgroups
  244. Returns the ids of the user's supplementary groups.
  245. =item getlogin
  246. This is identical to Perl's builtin C<getlogin()> function.
  247. =item getpgrp
  248. This is identical to Perl's builtin C<getpgrp()> function.
  249. =item getpid
  250. Returns the process's id.
  251. =item getppid
  252. This is identical to Perl's builtin C<getppid()> function.
  253. =item getpwnam
  254. This is identical to Perl's builtin C<getpwnam()> function.
  255. =item getpwuid
  256. This is identical to Perl's builtin C<getpwuid()> function.
  257. =item gets
  258. Returns one line from STDIN.
  259. =item getuid
  260. Returns the user's id.
  261. =item gmtime
  262. This is identical to Perl's builtin C<gmtime()> function.
  263. =item isalnum
  264. This is identical to the C function, except that it can apply to a single
  265. character or to a whole string.
  266. =item isalpha
  267. This is identical to the C function, except that it can apply to a single
  268. character or to a whole string.
  269. =item isatty
  270. Returns a boolean indicating whether the specified filehandle is connected
  271. to a tty.
  272. =item iscntrl
  273. This is identical to the C function, except that it can apply to a single
  274. character or to a whole string.
  275. =item isdigit
  276. This is identical to the C function, except that it can apply to a single
  277. character or to a whole string.
  278. =item isgraph
  279. This is identical to the C function, except that it can apply to a single
  280. character or to a whole string.
  281. =item islower
  282. This is identical to the C function, except that it can apply to a single
  283. character or to a whole string.
  284. =item isprint
  285. This is identical to the C function, except that it can apply to a single
  286. character or to a whole string.
  287. =item ispunct
  288. This is identical to the C function, except that it can apply to a single
  289. character or to a whole string.
  290. =item isspace
  291. This is identical to the C function, except that it can apply to a single
  292. character or to a whole string.
  293. =item isupper
  294. This is identical to the C function, except that it can apply to a single
  295. character or to a whole string.
  296. =item isxdigit
  297. This is identical to the C function, except that it can apply to a single
  298. character or to a whole string.
  299. =item kill
  300. This is identical to Perl's builtin C<kill()> function.
  301. =item labs
  302. labs() is C-specific, use abs instead.
  303. =item ldexp
  304. This is identical to the C function C<ldexp()>.
  305. =item ldiv
  306. ldiv() is C-specific, use / and int instead.
  307. =item link
  308. This is identical to Perl's builtin C<link()> function.
  309. =item localeconv
  310. Get numeric formatting information. Returns a reference to a hash
  311. containing the current locale formatting values.
  312. The database for the B<de> (Deutsch or German) locale.
  313. $loc = POSIX::setlocale( &POSIX::LC_ALL, "de" );
  314. print "Locale = $loc\n";
  315. $lconv = POSIX::localeconv();
  316. print "decimal_point = ", $lconv->{decimal_point}, "\n";
  317. print "thousands_sep = ", $lconv->{thousands_sep}, "\n";
  318. print "grouping = ", $lconv->{grouping}, "\n";
  319. print "int_curr_symbol = ", $lconv->{int_curr_symbol}, "\n";
  320. print "currency_symbol = ", $lconv->{currency_symbol}, "\n";
  321. print "mon_decimal_point = ", $lconv->{mon_decimal_point}, "\n";
  322. print "mon_thousands_sep = ", $lconv->{mon_thousands_sep}, "\n";
  323. print "mon_grouping = ", $lconv->{mon_grouping}, "\n";
  324. print "positive_sign = ", $lconv->{positive_sign}, "\n";
  325. print "negative_sign = ", $lconv->{negative_sign}, "\n";
  326. print "int_frac_digits = ", $lconv->{int_frac_digits}, "\n";
  327. print "frac_digits = ", $lconv->{frac_digits}, "\n";
  328. print "p_cs_precedes = ", $lconv->{p_cs_precedes}, "\n";
  329. print "p_sep_by_space = ", $lconv->{p_sep_by_space}, "\n";
  330. print "n_cs_precedes = ", $lconv->{n_cs_precedes}, "\n";
  331. print "n_sep_by_space = ", $lconv->{n_sep_by_space}, "\n";
  332. print "p_sign_posn = ", $lconv->{p_sign_posn}, "\n";
  333. print "n_sign_posn = ", $lconv->{n_sign_posn}, "\n";
  334. =item localtime
  335. This is identical to Perl's builtin C<localtime()> function.
  336. =item log
  337. This is identical to Perl's builtin C<log()> function.
  338. =item log10
  339. This is identical to the C function C<log10()>.
  340. =item longjmp
  341. longjmp() is C-specific: use die instead.
  342. =item lseek
  343. Move the file's read/write position. This uses file descriptors such as
  344. those obtained by calling C<POSIX::open>.
  345. $fd = POSIX::open( "foo", &POSIX::O_RDONLY );
  346. $off_t = POSIX::lseek( $fd, 0, &POSIX::SEEK_SET );
  347. Returns C<undef> on failure.
  348. =item malloc
  349. malloc() is C-specific.
  350. =item mblen
  351. This is identical to the C function C<mblen()>.
  352. =item mbstowcs
  353. This is identical to the C function C<mbstowcs()>.
  354. =item mbtowc
  355. This is identical to the C function C<mbtowc()>.
  356. =item memchr
  357. memchr() is C-specific, use index() instead.
  358. =item memcmp
  359. memcmp() is C-specific, use eq instead.
  360. =item memcpy
  361. memcpy() is C-specific, use = instead.
  362. =item memmove
  363. memmove() is C-specific, use = instead.
  364. =item memset
  365. memset() is C-specific, use x instead.
  366. =item mkdir
  367. This is identical to Perl's builtin C<mkdir()> function.
  368. =item mkfifo
  369. This is similar to the C function C<mkfifo()>.
  370. Returns C<undef> on failure.
  371. =item mktime
  372. Convert date/time info to a calendar time.
  373. Synopsis:
  374. mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
  375. The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero.
  376. I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The
  377. year (C<year>) is given in years since 1900. I.e. The year 1995 is 95; the
  378. year 2001 is 101. Consult your system's C<mktime()> manpage for details
  379. about these and the other arguments.
  380. Calendar time for December 12, 1995, at 10:30 am.
  381. $time_t = POSIX::mktime( 0, 30, 10, 12, 11, 95 );
  382. print "Date = ", POSIX::ctime($time_t);
  383. Returns C<undef> on failure.
  384. =item modf
  385. Return the integral and fractional parts of a floating-point number.
  386. ($fractional, $integral) = POSIX::modf( 3.14 );
  387. =item nice
  388. This is similar to the C function C<nice()>.
  389. Returns C<undef> on failure.
  390. =item offsetof
  391. offsetof() is C-specific.
  392. =item open
  393. Open a file for reading for writing. This returns file descriptors, not
  394. Perl filehandles. Use C<POSIX::close> to close the file.
  395. Open a file read-only with mode 0666.
  396. $fd = POSIX::open( "foo" );
  397. Open a file for read and write.
  398. $fd = POSIX::open( "foo", &POSIX::O_RDWR );
  399. Open a file for write, with truncation.
  400. $fd = POSIX::open( "foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC );
  401. Create a new file with mode 0640. Set up the file for writing.
  402. $fd = POSIX::open( "foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0640 );
  403. Returns C<undef> on failure.
  404. =item opendir
  405. Open a directory for reading.
  406. $dir = POSIX::opendir( "/tmp" );
  407. @files = POSIX::readdir( $dir );
  408. POSIX::closedir( $dir );
  409. Returns C<undef> on failure.
  410. =item pathconf
  411. Retrieves the value of a configurable limit on a file or directory.
  412. The following will determine the maximum length of the longest allowable
  413. pathname on the filesystem which holds C</tmp>.
  414. $path_max = POSIX::pathconf( "/tmp", &POSIX::_PC_PATH_MAX );
  415. Returns C<undef> on failure.
  416. =item pause
  417. This is similar to the C function C<pause()>.
  418. Returns C<undef> on failure.
  419. =item perror
  420. This is identical to the C function C<perror()>.
  421. =item pipe
  422. Create an interprocess channel. This returns file descriptors like those
  423. returned by C<POSIX::open>.
  424. ($fd0, $fd1) = POSIX::pipe();
  425. POSIX::write( $fd0, "hello", 5 );
  426. POSIX::read( $fd1, $buf, 5 );
  427. =item pow
  428. Computes $x raised to the power $exponent.
  429. $ret = POSIX::pow( $x, $exponent );
  430. =item printf
  431. Prints the specified arguments to STDOUT.
  432. =item putc
  433. putc() is C-specific--use print instead.
  434. =item putchar
  435. putchar() is C-specific--use print instead.
  436. =item puts
  437. puts() is C-specific--use print instead.
  438. =item qsort
  439. qsort() is C-specific, use sort instead.
  440. =item raise
  441. Sends the specified signal to the current process.
  442. =item rand
  443. rand() is non-portable, use Perl's rand instead.
  444. =item read
  445. Read from a file. This uses file descriptors such as those obtained by
  446. calling C<POSIX::open>. If the buffer C<$buf> is not large enough for the
  447. read then Perl will extend it to make room for the request.
  448. $fd = POSIX::open( "foo", &POSIX::O_RDONLY );
  449. $bytes = POSIX::read( $fd, $buf, 3 );
  450. Returns C<undef> on failure.
  451. =item readdir
  452. This is identical to Perl's builtin C<readdir()> function.
  453. =item realloc
  454. realloc() is C-specific.
  455. =item remove
  456. This is identical to Perl's builtin C<unlink()> function.
  457. =item rename
  458. This is identical to Perl's builtin C<rename()> function.
  459. =item rewind
  460. Seeks to the beginning of the file.
  461. =item rewinddir
  462. This is identical to Perl's builtin C<rewinddir()> function.
  463. =item rmdir
  464. This is identical to Perl's builtin C<rmdir()> function.
  465. =item scanf
  466. scanf() is C-specific--use <> and regular expressions instead.
  467. =item setgid
  468. Sets the real group id for this process.
  469. =item setjmp
  470. setjmp() is C-specific: use eval {} instead.
  471. =item setlocale
  472. Modifies and queries program's locale.
  473. The following will set the traditional UNIX system locale behavior
  474. (the second argument C<"C">).
  475. $loc = POSIX::setlocale( &POSIX::LC_ALL, "C" );
  476. The following will query (the missing second argument) the current
  477. LC_CTYPE category.
  478. $loc = POSIX::setlocale( &POSIX::LC_CTYPE);
  479. The following will set the LC_CTYPE behaviour according to the locale
  480. environment variables (the second argument C<"">).
  481. Please see your systems L<setlocale(3)> documentation for the locale
  482. environment variables' meaning or consult L<perllocale>.
  483. $loc = POSIX::setlocale( &POSIX::LC_CTYPE, "");
  484. The following will set the LC_COLLATE behaviour to Argentinian
  485. Spanish. B<NOTE>: The naming and availability of locales depends on
  486. your operating system. Please consult L<perllocale> for how to find
  487. out which locales are available in your system.
  488. $loc = POSIX::setlocale( &POSIX::LC_ALL, "es_AR.ISO8859-1" );
  489. =item setpgid
  490. This is similar to the C function C<setpgid()>.
  491. Returns C<undef> on failure.
  492. =item setsid
  493. This is identical to the C function C<setsid()>.
  494. =item setuid
  495. Sets the real user id for this process.
  496. =item sigaction
  497. Detailed signal management. This uses C<POSIX::SigAction> objects for the
  498. C<action> and C<oldaction> arguments. Consult your system's C<sigaction>
  499. manpage for details.
  500. Synopsis:
  501. sigaction(sig, action, oldaction = 0)
  502. Returns C<undef> on failure.
  503. =item siglongjmp
  504. siglongjmp() is C-specific: use die instead.
  505. =item sigpending
  506. Examine signals that are blocked and pending. This uses C<POSIX::SigSet>
  507. objects for the C<sigset> argument. Consult your system's C<sigpending>
  508. manpage for details.
  509. Synopsis:
  510. sigpending(sigset)
  511. Returns C<undef> on failure.
  512. =item sigprocmask
  513. Change and/or examine calling process's signal mask. This uses
  514. C<POSIX::SigSet> objects for the C<sigset> and C<oldsigset> arguments.
  515. Consult your system's C<sigprocmask> manpage for details.
  516. Synopsis:
  517. sigprocmask(how, sigset, oldsigset = 0)
  518. Returns C<undef> on failure.
  519. =item sigsetjmp
  520. sigsetjmp() is C-specific: use eval {} instead.
  521. =item sigsuspend
  522. Install a signal mask and suspend process until signal arrives. This uses
  523. C<POSIX::SigSet> objects for the C<signal_mask> argument. Consult your
  524. system's C<sigsuspend> manpage for details.
  525. Synopsis:
  526. sigsuspend(signal_mask)
  527. Returns C<undef> on failure.
  528. =item sin
  529. This is identical to Perl's builtin C<sin()> function.
  530. =item sinh
  531. This is identical to the C function C<sinh()>.
  532. =item sleep
  533. This is identical to Perl's builtin C<sleep()> function.
  534. =item sprintf
  535. This is identical to Perl's builtin C<sprintf()> function.
  536. =item sqrt
  537. This is identical to Perl's builtin C<sqrt()> function.
  538. =item srand
  539. srand().
  540. =item sscanf
  541. sscanf() is C-specific--use regular expressions instead.
  542. =item stat
  543. This is identical to Perl's builtin C<stat()> function.
  544. =item strcat
  545. strcat() is C-specific, use .= instead.
  546. =item strchr
  547. strchr() is C-specific, use index() instead.
  548. =item strcmp
  549. strcmp() is C-specific, use eq instead.
  550. =item strcoll
  551. This is identical to the C function C<strcoll()>.
  552. =item strcpy
  553. strcpy() is C-specific, use = instead.
  554. =item strcspn
  555. strcspn() is C-specific, use regular expressions instead.
  556. =item strerror
  557. Returns the error string for the specified errno.
  558. =item strftime
  559. Convert date and time information to string. Returns the string.
  560. Synopsis:
  561. strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
  562. The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero.
  563. I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The
  564. year (C<year>) is given in years since 1900. I.e., the year 1995 is 95; the
  565. year 2001 is 101. Consult your system's C<strftime()> manpage for details
  566. about these and the other arguments. The given arguments are made consistent
  567. by calling C<mktime()> before calling your system's C<strftime()> function.
  568. The string for Tuesday, December 12, 1995.
  569. $str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 );
  570. print "$str\n";
  571. =item strlen
  572. strlen() is C-specific, use length instead.
  573. =item strncat
  574. strncat() is C-specific, use .= instead.
  575. =item strncmp
  576. strncmp() is C-specific, use eq instead.
  577. =item strncpy
  578. strncpy() is C-specific, use = instead.
  579. =item stroul
  580. stroul() is C-specific.
  581. =item strpbrk
  582. strpbrk() is C-specific.
  583. =item strrchr
  584. strrchr() is C-specific, use rindex() instead.
  585. =item strspn
  586. strspn() is C-specific.
  587. =item strstr
  588. This is identical to Perl's builtin C<index()> function.
  589. =item strtod
  590. String to double translation. Returns the parsed number and the number
  591. of characters in the unparsed portion of the string. Truly
  592. POSIX-compliant systems set $! ($ERRNO) to indicate a translation
  593. error, so clear $! before calling strtod. However, non-POSIX systems
  594. may not check for overflow, and therefore will never set $!.
  595. strtod should respect any POSIX I<setlocale()> settings.
  596. To parse a string $str as a floating point number use
  597. $! = 0;
  598. ($num, $n_unparsed) = POSIX::strtod($str);
  599. The second returned item and $! can be used to check for valid input:
  600. if (($str eq '') || ($n_unparsed != 0) || !$!) {
  601. die "Non-numeric input $str" . $! ? ": $!\n" : "\n";
  602. }
  603. When called in a scalar context strtod returns the parsed number.
  604. =item strtok
  605. strtok() is C-specific.
  606. =item strtol
  607. String to (long) integer translation. Returns the parsed number and
  608. the number of characters in the unparsed portion of the string. Truly
  609. POSIX-compliant systems set $! ($ERRNO) to indicate a translation
  610. error, so clear $! before calling strtol. However, non-POSIX systems
  611. may not check for overflow, and therefore will never set $!.
  612. strtol should respect any POSIX I<setlocale()> settings.
  613. To parse a string $str as a number in some base $base use
  614. $! = 0;
  615. ($num, $n_unparsed) = POSIX::strtol($str, $base);
  616. The base should be zero or between 2 and 36, inclusive. When the base
  617. is zero or omitted strtol will use the string itself to determine the
  618. base: a leading "0x" or "0X" means hexadecimal; a leading "0" means
  619. octal; any other leading characters mean decimal. Thus, "1234" is
  620. parsed as a decimal number, "01234" as an octal number, and "0x1234"
  621. as a hexadecimal number.
  622. The second returned item and $! can be used to check for valid input:
  623. if (($str eq '') || ($n_unparsed != 0) || !$!) {
  624. die "Non-numeric input $str" . $! ? ": $!\n" : "\n";
  625. }
  626. When called in a scalar context strtol returns the parsed number.
  627. =item strtoul
  628. String to unsigned (long) integer translation. strtoul is identical
  629. to strtol except that strtoul only parses unsigned integers. See
  630. I<strtol> for details.
  631. Note: Some vendors supply strtod and strtol but not strtoul.
  632. Other vendors that do suply strtoul parse "-1" as a valid value.
  633. =item strxfrm
  634. String transformation. Returns the transformed string.
  635. $dst = POSIX::strxfrm( $src );
  636. =item sysconf
  637. Retrieves values of system configurable variables.
  638. The following will get the machine's clock speed.
  639. $clock_ticks = POSIX::sysconf( &POSIX::_SC_CLK_TCK );
  640. Returns C<undef> on failure.
  641. =item system
  642. This is identical to Perl's builtin C<system()> function.
  643. =item tan
  644. This is identical to the C function C<tan()>.
  645. =item tanh
  646. This is identical to the C function C<tanh()>.
  647. =item tcdrain
  648. This is similar to the C function C<tcdrain()>.
  649. Returns C<undef> on failure.
  650. =item tcflow
  651. This is similar to the C function C<tcflow()>.
  652. Returns C<undef> on failure.
  653. =item tcflush
  654. This is similar to the C function C<tcflush()>.
  655. Returns C<undef> on failure.
  656. =item tcgetpgrp
  657. This is identical to the C function C<tcgetpgrp()>.
  658. =item tcsendbreak
  659. This is similar to the C function C<tcsendbreak()>.
  660. Returns C<undef> on failure.
  661. =item tcsetpgrp
  662. This is similar to the C function C<tcsetpgrp()>.
  663. Returns C<undef> on failure.
  664. =item time
  665. This is identical to Perl's builtin C<time()> function.
  666. =item times
  667. The times() function returns elapsed realtime since some point in the past
  668. (such as system startup), user and system times for this process, and user
  669. and system times used by child processes. All times are returned in clock
  670. ticks.
  671. ($realtime, $user, $system, $cuser, $csystem) = POSIX::times();
  672. Note: Perl's builtin C<times()> function returns four values, measured in
  673. seconds.
  674. =item tmpfile
  675. Use method C<IO::File::new_tmpfile()> instead.
  676. =item tmpnam
  677. Returns a name for a temporary file.
  678. $tmpfile = POSIX::tmpnam();
  679. =item tolower
  680. This is identical to Perl's builtin C<lc()> function.
  681. =item toupper
  682. This is identical to Perl's builtin C<uc()> function.
  683. =item ttyname
  684. This is identical to the C function C<ttyname()>.
  685. =item tzname
  686. Retrieves the time conversion information from the C<tzname> variable.
  687. POSIX::tzset();
  688. ($std, $dst) = POSIX::tzname();
  689. =item tzset
  690. This is identical to the C function C<tzset()>.
  691. =item umask
  692. This is identical to Perl's builtin C<umask()> function.
  693. =item uname
  694. Get name of current operating system.
  695. ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
  696. =item ungetc
  697. Use method C<IO::Handle::ungetc()> instead.
  698. =item unlink
  699. This is identical to Perl's builtin C<unlink()> function.
  700. =item utime
  701. This is identical to Perl's builtin C<utime()> function.
  702. =item vfprintf
  703. vfprintf() is C-specific.
  704. =item vprintf
  705. vprintf() is C-specific.
  706. =item vsprintf
  707. vsprintf() is C-specific.
  708. =item wait
  709. This is identical to Perl's builtin C<wait()> function.
  710. =item waitpid
  711. Wait for a child process to change state. This is identical to Perl's
  712. builtin C<waitpid()> function.
  713. $pid = POSIX::waitpid( -1, &POSIX::WNOHANG );
  714. print "status = ", ($? / 256), "\n";
  715. =item wcstombs
  716. This is identical to the C function C<wcstombs()>.
  717. =item wctomb
  718. This is identical to the C function C<wctomb()>.
  719. =item write
  720. Write to a file. This uses file descriptors such as those obtained by
  721. calling C<POSIX::open>.
  722. $fd = POSIX::open( "foo", &POSIX::O_WRONLY );
  723. $buf = "hello";
  724. $bytes = POSIX::write( $b, $buf, 5 );
  725. Returns C<undef> on failure.
  726. =back
  727. =head1 CLASSES
  728. =head2 POSIX::SigAction
  729. =over 8
  730. =item new
  731. Creates a new C<POSIX::SigAction> object which corresponds to the C
  732. C<struct sigaction>. This object will be destroyed automatically when it is
  733. no longer needed. The first parameter is the fully-qualified name of a sub
  734. which is a signal-handler. The second parameter is a C<POSIX::SigSet>
  735. object, it defaults to the empty set. The third parameter contains the
  736. C<sa_flags>, it defaults to 0.
  737. $sigset = POSIX::SigSet->new(SIGINT, SIGQUIT);
  738. $sigaction = POSIX::SigAction->new( 'main::handler', $sigset, &POSIX::SA_NOCLDSTOP );
  739. This C<POSIX::SigAction> object should be used with the C<POSIX::sigaction()>
  740. function.
  741. =back
  742. =head2 POSIX::SigSet
  743. =over 8
  744. =item new
  745. Create a new SigSet object. This object will be destroyed automatically
  746. when it is no longer needed. Arguments may be supplied to initialize the
  747. set.
  748. Create an empty set.
  749. $sigset = POSIX::SigSet->new;
  750. Create a set with SIGUSR1.
  751. $sigset = POSIX::SigSet->new( &POSIX::SIGUSR1 );
  752. =item addset
  753. Add a signal to a SigSet object.
  754. $sigset->addset( &POSIX::SIGUSR2 );
  755. Returns C<undef> on failure.
  756. =item delset
  757. Remove a signal from the SigSet object.
  758. $sigset->delset( &POSIX::SIGUSR2 );
  759. Returns C<undef> on failure.
  760. =item emptyset
  761. Initialize the SigSet object to be empty.
  762. $sigset->emptyset();
  763. Returns C<undef> on failure.
  764. =item fillset
  765. Initialize the SigSet object to include all signals.
  766. $sigset->fillset();
  767. Returns C<undef> on failure.
  768. =item ismember
  769. Tests the SigSet object to see if it contains a specific signal.
  770. if( $sigset->ismember( &POSIX::SIGUSR1 ) ){
  771. print "contains SIGUSR1\n";
  772. }
  773. =back
  774. =head2 POSIX::Termios
  775. =over 8
  776. =item new
  777. Create a new Termios object. This object will be destroyed automatically
  778. when it is no longer needed. A Termios object corresponds to the termios
  779. C struct. new() mallocs a new one, getattr() fills it from a file descriptor,
  780. and setattr() sets a file descriptor's parameters to match Termios' contents.
  781. $termios = POSIX::Termios->new;
  782. =item getattr
  783. Get terminal control attributes.
  784. Obtain the attributes for stdin.
  785. $termios->getattr()
  786. Obtain the attributes for stdout.
  787. $termios->getattr( 1 )
  788. Returns C<undef> on failure.
  789. =item getcc
  790. Retrieve a value from the c_cc field of a termios object. The c_cc field is
  791. an array so an index must be specified.
  792. $c_cc[1] = $termios->getcc(1);
  793. =item getcflag
  794. Retrieve the c_cflag field of a termios object.
  795. $c_cflag = $termios->getcflag;
  796. =item getiflag
  797. Retrieve the c_iflag field of a termios object.
  798. $c_iflag = $termios->getiflag;
  799. =item getispeed
  800. Retrieve the input baud rate.
  801. $ispeed = $termios->getispeed;
  802. =item getlflag
  803. Retrieve the c_lflag field of a termios object.
  804. $c_lflag = $termios->getlflag;
  805. =item getoflag
  806. Retrieve the c_oflag field of a termios object.
  807. $c_oflag = $termios->getoflag;
  808. =item getospeed
  809. Retrieve the output baud rate.
  810. $ospeed = $termios->getospeed;
  811. =item setattr
  812. Set terminal control attributes.
  813. Set attributes immediately for stdout.
  814. $termios->setattr( 1, &POSIX::TCSANOW );
  815. Returns C<undef> on failure.
  816. =item setcc
  817. Set a value in the c_cc field of a termios object. The c_cc field is an
  818. array so an index must be specified.
  819. $termios->setcc( &POSIX::VEOF, 1 );
  820. =item setcflag
  821. Set the c_cflag field of a termios object.
  822. $termios->setcflag( $c_cflag | &POSIX::CLOCAL );
  823. =item setiflag
  824. Set the c_iflag field of a termios object.
  825. $termios->setiflag( $c_iflag | &POSIX::BRKINT );
  826. =item setispeed
  827. Set the input baud rate.
  828. $termios->setispeed( &POSIX::B9600 );
  829. Returns C<undef> on failure.
  830. =item setlflag
  831. Set the c_lflag field of a termios object.
  832. $termios->setlflag( $c_lflag | &POSIX::ECHO );
  833. =item setoflag
  834. Set the c_oflag field of a termios object.
  835. $termios->setoflag( $c_oflag | &POSIX::OPOST );
  836. =item setospeed
  837. Set the output baud rate.
  838. $termios->setospeed( &POSIX::B9600 );
  839. Returns C<undef> on failure.
  840. =item Baud rate values
  841. B38400 B75 B200 B134 B300 B1800 B150 B0 B19200 B1200 B9600 B600 B4800 B50 B2400 B110
  842. =item Terminal interface values
  843. TCSADRAIN TCSANOW TCOON TCIOFLUSH TCOFLUSH TCION TCIFLUSH TCSAFLUSH TCIOFF TCOOFF
  844. =item c_cc field values
  845. VEOF VEOL VERASE VINTR VKILL VQUIT VSUSP VSTART VSTOP VMIN VTIME NCCS
  846. =item c_cflag field values
  847. CLOCAL CREAD CSIZE CS5 CS6 CS7 CS8 CSTOPB HUPCL PARENB PARODD
  848. =item c_iflag field values
  849. BRKINT ICRNL IGNBRK IGNCR IGNPAR INLCR INPCK ISTRIP IXOFF IXON PARMRK
  850. =item c_lflag field values
  851. ECHO ECHOE ECHOK ECHONL ICANON IEXTEN ISIG NOFLSH TOSTOP
  852. =item c_oflag field values
  853. OPOST
  854. =back
  855. =head1 PATHNAME CONSTANTS
  856. =over 8
  857. =item Constants
  858. _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
  859. =back
  860. =head1 POSIX CONSTANTS
  861. =over 8
  862. =item Constants
  863. _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
  864. =back
  865. =head1 SYSTEM CONFIGURATION
  866. =over 8
  867. =item Constants
  868. _SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_SAVED_IDS _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
  869. =back
  870. =head1 ERRNO
  871. =over 8
  872. =item Constants
  873. E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT EAGAIN EALREADY EBADF
  874. EBUSY ECHILD ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ
  875. EDOM EDQUOT EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH EINPROGRESS EINTR
  876. EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE ENAMETOOLONG
  877. ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODEV ENOENT ENOEXEC
  878. ENOLCK ENOMEM ENOPROTOOPT ENOSPC ENOSYS ENOTBLK ENOTCONN ENOTDIR
  879. ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM EPFNOSUPPORT EPIPE
  880. EPROCLIM EPROTONOSUPPORT EPROTOTYPE ERANGE EREMOTE ERESTART EROFS
  881. ESHUTDOWN ESOCKTNOSUPPORT ESPIPE ESRCH ESTALE ETIMEDOUT ETOOMANYREFS
  882. ETXTBSY EUSERS EWOULDBLOCK EXDEV
  883. =back
  884. =head1 FCNTL
  885. =over 8
  886. =item Constants
  887. 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
  888. =back
  889. =head1 FLOAT
  890. =over 8
  891. =item Constants
  892. 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
  893. =back
  894. =head1 LIMITS
  895. =over 8
  896. =item Constants
  897. 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
  898. =back
  899. =head1 LOCALE
  900. =over 8
  901. =item Constants
  902. LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME
  903. =back
  904. =head1 MATH
  905. =over 8
  906. =item Constants
  907. HUGE_VAL
  908. =back
  909. =head1 SIGNAL
  910. =over 8
  911. =item Constants
  912. SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK SA_RESETHAND SA_RESTART
  913. SA_SIGINFO SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT
  914. SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU
  915. SIGUSR1 SIGUSR2 SIG_BLOCK SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK
  916. SIG_UNBLOCK
  917. =back
  918. =head1 STAT
  919. =over 8
  920. =item Constants
  921. 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
  922. =item Macros
  923. S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG
  924. =back
  925. =head1 STDLIB
  926. =over 8
  927. =item Constants
  928. EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX RAND_MAX
  929. =back
  930. =head1 STDIO
  931. =over 8
  932. =item Constants
  933. BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid L_tmpname TMP_MAX
  934. =back
  935. =head1 TIME
  936. =over 8
  937. =item Constants
  938. CLK_TCK CLOCKS_PER_SEC
  939. =back
  940. =head1 UNISTD
  941. =over 8
  942. =item Constants
  943. R_OK SEEK_CUR SEEK_END SEEK_SET STDIN_FILENO STDOUT_FILENO STRERR_FILENO W_OK X_OK
  944. =back
  945. =head1 WAIT
  946. =over 8
  947. =item Constants
  948. WNOHANG WUNTRACED
  949. =item Macros
  950. WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG
  951. =back
  952. =head1 CREATION
  953. This document generated by ./mkposixman.PL version 19960129.