diff options
Diffstat (limited to 'meta/recipes-devtools/perl/perl-5.12.3/parallel_build_fix_3.patch')
| -rw-r--r-- | meta/recipes-devtools/perl/perl-5.12.3/parallel_build_fix_3.patch | 6585 |
1 files changed, 0 insertions, 6585 deletions
diff --git a/meta/recipes-devtools/perl/perl-5.12.3/parallel_build_fix_3.patch b/meta/recipes-devtools/perl/perl-5.12.3/parallel_build_fix_3.patch deleted file mode 100644 index 26af1f1d95..0000000000 --- a/meta/recipes-devtools/perl/perl-5.12.3/parallel_build_fix_3.patch +++ /dev/null | |||
| @@ -1,6585 +0,0 @@ | |||
| 1 | Upstream-Status:Inappropriate [Backport] | ||
| 2 | |||
| 3 | Imported from perl git tree by Nitin A Kamble <nitin.a.kamble@intel.com> | ||
| 4 | 2011-02-23 | ||
| 5 | |||
| 6 | commit 4feb80ac47a22e7de7d7c1c1d5dfb3d744a2a3a7 | ||
| 7 | Author: Jerry D. Hedden <jdhedden@cpan.org> | ||
| 8 | Date: Tue Aug 17 13:17:11 2010 -0400 | ||
| 9 | |||
| 10 | Move POSIX.pm to lib/POSIX.pm to fix autosplitter problem | ||
| 11 | |||
| 12 | diff --git a/MANIFEST b/MANIFEST | ||
| 13 | index 3036d73..faf8974 100644 | ||
| 14 | --- a/MANIFEST | ||
| 15 | +++ b/MANIFEST | ||
| 16 | @@ -3183,9 +3183,9 @@ ext/POSIX/hints/openbsd.pl Hint for POSIX for named architecture | ||
| 17 | ext/POSIX/hints/sunos_4.pl Hint for POSIX for named architecture | ||
| 18 | ext/POSIX/hints/svr4.pl Hint for POSIX for named architecture | ||
| 19 | ext/POSIX/hints/uts.pl Hint for POSIX for named architecture | ||
| 20 | +ext/POSIX/lib/POSIX.pm POSIX extension Perl module | ||
| 21 | +ext/POSIX/lib/POSIX.pod POSIX extension documentation | ||
| 22 | ext/POSIX/Makefile.PL POSIX extension makefile writer | ||
| 23 | -ext/POSIX/POSIX.pm POSIX extension Perl module | ||
| 24 | -ext/POSIX/POSIX.pod POSIX extension documentation | ||
| 25 | ext/POSIX/POSIX.xs POSIX extension external subroutines | ||
| 26 | ext/POSIX/t/is.t See if POSIX isxxx() work | ||
| 27 | ext/POSIX/t/math.t Basic math tests for POSIX | ||
| 28 | diff --git a/ext/POSIX/Makefile.PL b/ext/POSIX/Makefile.PL | ||
| 29 | index 292882c..07c3841 100644 | ||
| 30 | --- a/ext/POSIX/Makefile.PL | ||
| 31 | +++ b/ext/POSIX/Makefile.PL | ||
| 32 | @@ -18,7 +18,8 @@ WriteMakefile( | ||
| 33 | NAME => 'POSIX', | ||
| 34 | @libs, | ||
| 35 | XSPROTOARG => '-noprototypes', # XXX remove later? | ||
| 36 | - VERSION_FROM => 'POSIX.pm', | ||
| 37 | + VERSION_FROM => 'lib/POSIX.pm', | ||
| 38 | + ABSTRACT_FROM => 'lib/POSIX.pod', | ||
| 39 | realclean => {FILES=> 'const-c.inc const-xs.inc'}, | ||
| 40 | ); | ||
| 41 | |||
| 42 | diff --git a/ext/POSIX/POSIX.pm b/ext/POSIX/POSIX.pm | ||
| 43 | deleted file mode 100644 | ||
| 44 | index ffbd9de..0000000 | ||
| 45 | --- a/ext/POSIX/POSIX.pm | ||
| 46 | +++ /dev/null | ||
| 47 | @@ -1,1042 +0,0 @@ | ||
| 48 | -package POSIX; | ||
| 49 | -use strict; | ||
| 50 | -use warnings; | ||
| 51 | - | ||
| 52 | -our(@ISA, %EXPORT_TAGS, @EXPORT_OK, @EXPORT, $AUTOLOAD, %SIGRT) = (); | ||
| 53 | - | ||
| 54 | -our $VERSION = "1.19"; | ||
| 55 | - | ||
| 56 | -use AutoLoader; | ||
| 57 | - | ||
| 58 | -use XSLoader (); | ||
| 59 | - | ||
| 60 | -use Fcntl qw(FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK F_SETFD | ||
| 61 | - F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK O_ACCMODE O_APPEND | ||
| 62 | - O_CREAT O_EXCL O_NOCTTY O_NONBLOCK O_RDONLY O_RDWR O_TRUNC | ||
| 63 | - O_WRONLY SEEK_CUR SEEK_END SEEK_SET | ||
| 64 | - S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG | ||
| 65 | - S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU S_ISGID S_ISUID | ||
| 66 | - S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR); | ||
| 67 | - | ||
| 68 | -# Grandfather old foo_h form to new :foo_h form | ||
| 69 | -my $loaded; | ||
| 70 | - | ||
| 71 | -sub import { | ||
| 72 | - load_imports() unless $loaded++; | ||
| 73 | - my $this = shift; | ||
| 74 | - my @list = map { m/^\w+_h$/ ? ":$_" : $_ } @_; | ||
| 75 | - local $Exporter::ExportLevel = 1; | ||
| 76 | - Exporter::import($this,@list); | ||
| 77 | -} | ||
| 78 | - | ||
| 79 | -sub croak { require Carp; goto &Carp::croak } | ||
| 80 | -# declare usage to assist AutoLoad | ||
| 81 | -sub usage; | ||
| 82 | - | ||
| 83 | -XSLoader::load 'POSIX', $VERSION; | ||
| 84 | - | ||
| 85 | -sub AUTOLOAD { | ||
| 86 | - no strict; | ||
| 87 | - no warnings 'uninitialized'; | ||
| 88 | - if ($AUTOLOAD =~ /::(_?[a-z])/) { | ||
| 89 | - # require AutoLoader; | ||
| 90 | - $AutoLoader::AUTOLOAD = $AUTOLOAD; | ||
| 91 | - goto &AutoLoader::AUTOLOAD | ||
| 92 | - } | ||
| 93 | - local $! = 0; | ||
| 94 | - my $constname = $AUTOLOAD; | ||
| 95 | - $constname =~ s/.*:://; | ||
| 96 | - my ($error, $val) = constant($constname); | ||
| 97 | - croak $error if $error; | ||
| 98 | - *$AUTOLOAD = sub { $val }; | ||
| 99 | - | ||
| 100 | - goto &$AUTOLOAD; | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | -package POSIX::SigAction; | ||
| 104 | - | ||
| 105 | -use AutoLoader 'AUTOLOAD'; | ||
| 106 | - | ||
| 107 | -package POSIX::SigRt; | ||
| 108 | - | ||
| 109 | -use AutoLoader 'AUTOLOAD'; | ||
| 110 | - | ||
| 111 | -use Tie::Hash; | ||
| 112 | - | ||
| 113 | -use vars qw($SIGACTION_FLAGS $_SIGRTMIN $_SIGRTMAX $_sigrtn @ISA); | ||
| 114 | -@POSIX::SigRt::ISA = qw(Tie::StdHash); | ||
| 115 | - | ||
| 116 | -$SIGACTION_FLAGS = 0; | ||
| 117 | - | ||
| 118 | -tie %POSIX::SIGRT, 'POSIX::SigRt'; | ||
| 119 | - | ||
| 120 | -sub DESTROY {}; | ||
| 121 | - | ||
| 122 | -package POSIX; | ||
| 123 | - | ||
| 124 | -1; | ||
| 125 | -__END__ | ||
| 126 | - | ||
| 127 | -sub usage { | ||
| 128 | - my ($mess) = @_; | ||
| 129 | - croak "Usage: POSIX::$mess"; | ||
| 130 | -} | ||
| 131 | - | ||
| 132 | -sub redef { | ||
| 133 | - my ($mess) = @_; | ||
| 134 | - croak "Use method $mess instead"; | ||
| 135 | -} | ||
| 136 | - | ||
| 137 | -sub unimpl { | ||
| 138 | - my ($mess) = @_; | ||
| 139 | - $mess =~ s/xxx//; | ||
| 140 | - croak "Unimplemented: POSIX::$mess"; | ||
| 141 | -} | ||
| 142 | - | ||
| 143 | -sub assert { | ||
| 144 | - usage "assert(expr)" if @_ != 1; | ||
| 145 | - if (!$_[0]) { | ||
| 146 | - croak "Assertion failed"; | ||
| 147 | - } | ||
| 148 | -} | ||
| 149 | - | ||
| 150 | -sub tolower { | ||
| 151 | - usage "tolower(string)" if @_ != 1; | ||
| 152 | - lc($_[0]); | ||
| 153 | -} | ||
| 154 | - | ||
| 155 | -sub toupper { | ||
| 156 | - usage "toupper(string)" if @_ != 1; | ||
| 157 | - uc($_[0]); | ||
| 158 | -} | ||
| 159 | - | ||
| 160 | -sub closedir { | ||
| 161 | - usage "closedir(dirhandle)" if @_ != 1; | ||
| 162 | - CORE::closedir($_[0]); | ||
| 163 | -} | ||
| 164 | - | ||
| 165 | -sub opendir { | ||
| 166 | - usage "opendir(directory)" if @_ != 1; | ||
| 167 | - my $dirhandle; | ||
| 168 | - CORE::opendir($dirhandle, $_[0]) | ||
| 169 | - ? $dirhandle | ||
| 170 | - : undef; | ||
| 171 | -} | ||
| 172 | - | ||
| 173 | -sub readdir { | ||
| 174 | - usage "readdir(dirhandle)" if @_ != 1; | ||
| 175 | - CORE::readdir($_[0]); | ||
| 176 | -} | ||
| 177 | - | ||
| 178 | -sub rewinddir { | ||
| 179 | - usage "rewinddir(dirhandle)" if @_ != 1; | ||
| 180 | - CORE::rewinddir($_[0]); | ||
| 181 | -} | ||
| 182 | - | ||
| 183 | -sub errno { | ||
| 184 | - usage "errno()" if @_ != 0; | ||
| 185 | - $! + 0; | ||
| 186 | -} | ||
| 187 | - | ||
| 188 | -sub creat { | ||
| 189 | - usage "creat(filename, mode)" if @_ != 2; | ||
| 190 | - &open($_[0], &O_WRONLY | &O_CREAT | &O_TRUNC, $_[1]); | ||
| 191 | -} | ||
| 192 | - | ||
| 193 | -sub fcntl { | ||
| 194 | - usage "fcntl(filehandle, cmd, arg)" if @_ != 3; | ||
| 195 | - CORE::fcntl($_[0], $_[1], $_[2]); | ||
| 196 | -} | ||
| 197 | - | ||
| 198 | -sub getgrgid { | ||
| 199 | - usage "getgrgid(gid)" if @_ != 1; | ||
| 200 | - CORE::getgrgid($_[0]); | ||
| 201 | -} | ||
| 202 | - | ||
| 203 | -sub getgrnam { | ||
| 204 | - usage "getgrnam(name)" if @_ != 1; | ||
| 205 | - CORE::getgrnam($_[0]); | ||
| 206 | -} | ||
| 207 | - | ||
| 208 | -sub atan2 { | ||
| 209 | - usage "atan2(x,y)" if @_ != 2; | ||
| 210 | - CORE::atan2($_[0], $_[1]); | ||
| 211 | -} | ||
| 212 | - | ||
| 213 | -sub cos { | ||
| 214 | - usage "cos(x)" if @_ != 1; | ||
| 215 | - CORE::cos($_[0]); | ||
| 216 | -} | ||
| 217 | - | ||
| 218 | -sub exp { | ||
| 219 | - usage "exp(x)" if @_ != 1; | ||
| 220 | - CORE::exp($_[0]); | ||
| 221 | -} | ||
| 222 | - | ||
| 223 | -sub fabs { | ||
| 224 | - usage "fabs(x)" if @_ != 1; | ||
| 225 | - CORE::abs($_[0]); | ||
| 226 | -} | ||
| 227 | - | ||
| 228 | -sub log { | ||
| 229 | - usage "log(x)" if @_ != 1; | ||
| 230 | - CORE::log($_[0]); | ||
| 231 | -} | ||
| 232 | - | ||
| 233 | -sub pow { | ||
| 234 | - usage "pow(x,exponent)" if @_ != 2; | ||
| 235 | - $_[0] ** $_[1]; | ||
| 236 | -} | ||
| 237 | - | ||
| 238 | -sub sin { | ||
| 239 | - usage "sin(x)" if @_ != 1; | ||
| 240 | - CORE::sin($_[0]); | ||
| 241 | -} | ||
| 242 | - | ||
| 243 | -sub sqrt { | ||
| 244 | - usage "sqrt(x)" if @_ != 1; | ||
| 245 | - CORE::sqrt($_[0]); | ||
| 246 | -} | ||
| 247 | - | ||
| 248 | -sub getpwnam { | ||
| 249 | - usage "getpwnam(name)" if @_ != 1; | ||
| 250 | - CORE::getpwnam($_[0]); | ||
| 251 | -} | ||
| 252 | - | ||
| 253 | -sub getpwuid { | ||
| 254 | - usage "getpwuid(uid)" if @_ != 1; | ||
| 255 | - CORE::getpwuid($_[0]); | ||
| 256 | -} | ||
| 257 | - | ||
| 258 | -sub longjmp { | ||
| 259 | - unimpl "longjmp() is C-specific: use die instead"; | ||
| 260 | -} | ||
| 261 | - | ||
| 262 | -sub setjmp { | ||
| 263 | - unimpl "setjmp() is C-specific: use eval {} instead"; | ||
| 264 | -} | ||
| 265 | - | ||
| 266 | -sub siglongjmp { | ||
| 267 | - unimpl "siglongjmp() is C-specific: use die instead"; | ||
| 268 | -} | ||
| 269 | - | ||
| 270 | -sub sigsetjmp { | ||
| 271 | - unimpl "sigsetjmp() is C-specific: use eval {} instead"; | ||
| 272 | -} | ||
| 273 | - | ||
| 274 | -sub kill { | ||
| 275 | - usage "kill(pid, sig)" if @_ != 2; | ||
| 276 | - CORE::kill $_[1], $_[0]; | ||
| 277 | -} | ||
| 278 | - | ||
| 279 | -sub raise { | ||
| 280 | - usage "raise(sig)" if @_ != 1; | ||
| 281 | - CORE::kill $_[0], $$; # Is this good enough? | ||
| 282 | -} | ||
| 283 | - | ||
| 284 | -sub offsetof { | ||
| 285 | - unimpl "offsetof() is C-specific, stopped"; | ||
| 286 | -} | ||
| 287 | - | ||
| 288 | -sub clearerr { | ||
| 289 | - redef "IO::Handle::clearerr()"; | ||
| 290 | -} | ||
| 291 | - | ||
| 292 | -sub fclose { | ||
| 293 | - redef "IO::Handle::close()"; | ||
| 294 | -} | ||
| 295 | - | ||
| 296 | -sub fdopen { | ||
| 297 | - redef "IO::Handle::new_from_fd()"; | ||
| 298 | -} | ||
| 299 | - | ||
| 300 | -sub feof { | ||
| 301 | - redef "IO::Handle::eof()"; | ||
| 302 | -} | ||
| 303 | - | ||
| 304 | -sub fgetc { | ||
| 305 | - redef "IO::Handle::getc()"; | ||
| 306 | -} | ||
| 307 | - | ||
| 308 | -sub fgets { | ||
| 309 | - redef "IO::Handle::gets()"; | ||
| 310 | -} | ||
| 311 | - | ||
| 312 | -sub fileno { | ||
| 313 | - redef "IO::Handle::fileno()"; | ||
| 314 | -} | ||
| 315 | - | ||
| 316 | -sub fopen { | ||
| 317 | - redef "IO::File::open()"; | ||
| 318 | -} | ||
| 319 | - | ||
| 320 | -sub fprintf { | ||
| 321 | - unimpl "fprintf() is C-specific--use printf instead"; | ||
| 322 | -} | ||
| 323 | - | ||
| 324 | -sub fputc { | ||
| 325 | - unimpl "fputc() is C-specific--use print instead"; | ||
| 326 | -} | ||
| 327 | - | ||
| 328 | -sub fputs { | ||
| 329 | - unimpl "fputs() is C-specific--use print instead"; | ||
| 330 | -} | ||
| 331 | - | ||
| 332 | -sub fread { | ||
| 333 | - unimpl "fread() is C-specific--use read instead"; | ||
| 334 | -} | ||
| 335 | - | ||
| 336 | -sub freopen { | ||
| 337 | - unimpl "freopen() is C-specific--use open instead"; | ||
| 338 | -} | ||
| 339 | - | ||
| 340 | -sub fscanf { | ||
| 341 | - unimpl "fscanf() is C-specific--use <> and regular expressions instead"; | ||
| 342 | -} | ||
| 343 | - | ||
| 344 | -sub fseek { | ||
| 345 | - redef "IO::Seekable::seek()"; | ||
| 346 | -} | ||
| 347 | - | ||
| 348 | -sub fsync { | ||
| 349 | - redef "IO::Handle::sync()"; | ||
| 350 | -} | ||
| 351 | - | ||
| 352 | -sub ferror { | ||
| 353 | - redef "IO::Handle::error()"; | ||
| 354 | -} | ||
| 355 | - | ||
| 356 | -sub fflush { | ||
| 357 | - redef "IO::Handle::flush()"; | ||
| 358 | -} | ||
| 359 | - | ||
| 360 | -sub fgetpos { | ||
| 361 | - redef "IO::Seekable::getpos()"; | ||
| 362 | -} | ||
| 363 | - | ||
| 364 | -sub fsetpos { | ||
| 365 | - redef "IO::Seekable::setpos()"; | ||
| 366 | -} | ||
| 367 | - | ||
| 368 | -sub ftell { | ||
| 369 | - redef "IO::Seekable::tell()"; | ||
| 370 | -} | ||
| 371 | - | ||
| 372 | -sub fwrite { | ||
| 373 | - unimpl "fwrite() is C-specific--use print instead"; | ||
| 374 | -} | ||
| 375 | - | ||
| 376 | -sub getc { | ||
| 377 | - usage "getc(handle)" if @_ != 1; | ||
| 378 | - CORE::getc($_[0]); | ||
| 379 | -} | ||
| 380 | - | ||
| 381 | -sub getchar { | ||
| 382 | - usage "getchar()" if @_ != 0; | ||
| 383 | - CORE::getc(STDIN); | ||
| 384 | -} | ||
| 385 | - | ||
| 386 | -sub gets { | ||
| 387 | - usage "gets()" if @_ != 0; | ||
| 388 | - scalar <STDIN>; | ||
| 389 | -} | ||
| 390 | - | ||
| 391 | -sub perror { | ||
| 392 | - print STDERR "@_: " if @_; | ||
| 393 | - print STDERR $!,"\n"; | ||
| 394 | -} | ||
| 395 | - | ||
| 396 | -sub printf { | ||
| 397 | - usage "printf(pattern, args...)" if @_ < 1; | ||
| 398 | - CORE::printf STDOUT @_; | ||
| 399 | -} | ||
| 400 | - | ||
| 401 | -sub putc { | ||
| 402 | - unimpl "putc() is C-specific--use print instead"; | ||
| 403 | -} | ||
| 404 | - | ||
| 405 | -sub putchar { | ||
| 406 | - unimpl "putchar() is C-specific--use print instead"; | ||
| 407 | -} | ||
| 408 | - | ||
| 409 | -sub puts { | ||
| 410 | - unimpl "puts() is C-specific--use print instead"; | ||
| 411 | -} | ||
| 412 | - | ||
| 413 | -sub remove { | ||
| 414 | - usage "remove(filename)" if @_ != 1; | ||
| 415 | - (-d $_[0]) ? CORE::rmdir($_[0]) : CORE::unlink($_[0]); | ||
| 416 | -} | ||
| 417 | - | ||
| 418 | -sub rename { | ||
| 419 | - usage "rename(oldfilename, newfilename)" if @_ != 2; | ||
| 420 | - CORE::rename($_[0], $_[1]); | ||
| 421 | -} | ||
| 422 | - | ||
| 423 | -sub rewind { | ||
| 424 | - usage "rewind(filehandle)" if @_ != 1; | ||
| 425 | - CORE::seek($_[0],0,0); | ||
| 426 | -} | ||
| 427 | - | ||
| 428 | -sub scanf { | ||
| 429 | - unimpl "scanf() is C-specific--use <> and regular expressions instead"; | ||
| 430 | -} | ||
| 431 | - | ||
| 432 | -sub sprintf { | ||
| 433 | - usage "sprintf(pattern,args)" if @_ == 0; | ||
| 434 | - CORE::sprintf(shift,@_); | ||
| 435 | -} | ||
| 436 | - | ||
| 437 | -sub sscanf { | ||
| 438 | - unimpl "sscanf() is C-specific--use regular expressions instead"; | ||
| 439 | -} | ||
| 440 | - | ||
| 441 | -sub tmpfile { | ||
| 442 | - redef "IO::File::new_tmpfile()"; | ||
| 443 | -} | ||
| 444 | - | ||
| 445 | -sub ungetc { | ||
| 446 | - redef "IO::Handle::ungetc()"; | ||
| 447 | -} | ||
| 448 | - | ||
| 449 | -sub vfprintf { | ||
| 450 | - unimpl "vfprintf() is C-specific"; | ||
| 451 | -} | ||
| 452 | - | ||
| 453 | -sub vprintf { | ||
| 454 | - unimpl "vprintf() is C-specific"; | ||
| 455 | -} | ||
| 456 | - | ||
| 457 | -sub vsprintf { | ||
| 458 | - unimpl "vsprintf() is C-specific"; | ||
| 459 | -} | ||
| 460 | - | ||
| 461 | -sub abs { | ||
| 462 | - usage "abs(x)" if @_ != 1; | ||
| 463 | - CORE::abs($_[0]); | ||
| 464 | -} | ||
| 465 | - | ||
| 466 | -sub atexit { | ||
| 467 | - unimpl "atexit() is C-specific: use END {} instead"; | ||
| 468 | -} | ||
| 469 | - | ||
| 470 | -sub atof { | ||
| 471 | - unimpl "atof() is C-specific, stopped"; | ||
| 472 | -} | ||
| 473 | - | ||
| 474 | -sub atoi { | ||
| 475 | - unimpl "atoi() is C-specific, stopped"; | ||
| 476 | -} | ||
| 477 | - | ||
| 478 | -sub atol { | ||
| 479 | - unimpl "atol() is C-specific, stopped"; | ||
| 480 | -} | ||
| 481 | - | ||
| 482 | -sub bsearch { | ||
| 483 | - unimpl "bsearch() not supplied"; | ||
| 484 | -} | ||
| 485 | - | ||
| 486 | -sub calloc { | ||
| 487 | - unimpl "calloc() is C-specific, stopped"; | ||
| 488 | -} | ||
| 489 | - | ||
| 490 | -sub div { | ||
| 491 | - unimpl "div() is C-specific, use /, % and int instead"; | ||
| 492 | -} | ||
| 493 | - | ||
| 494 | -sub exit { | ||
| 495 | - usage "exit(status)" if @_ != 1; | ||
| 496 | - CORE::exit($_[0]); | ||
| 497 | -} | ||
| 498 | - | ||
| 499 | -sub free { | ||
| 500 | - unimpl "free() is C-specific, stopped"; | ||
| 501 | -} | ||
| 502 | - | ||
| 503 | -sub getenv { | ||
| 504 | - usage "getenv(name)" if @_ != 1; | ||
| 505 | - $ENV{$_[0]}; | ||
| 506 | -} | ||
| 507 | - | ||
| 508 | -sub labs { | ||
| 509 | - unimpl "labs() is C-specific, use abs instead"; | ||
| 510 | -} | ||
| 511 | - | ||
| 512 | -sub ldiv { | ||
| 513 | - unimpl "ldiv() is C-specific, use /, % and int instead"; | ||
| 514 | -} | ||
| 515 | - | ||
| 516 | -sub malloc { | ||
| 517 | - unimpl "malloc() is C-specific, stopped"; | ||
| 518 | -} | ||
| 519 | - | ||
| 520 | -sub qsort { | ||
| 521 | - unimpl "qsort() is C-specific, use sort instead"; | ||
| 522 | -} | ||
| 523 | - | ||
| 524 | -sub rand { | ||
| 525 | - unimpl "rand() is non-portable, use Perl's rand instead"; | ||
| 526 | -} | ||
| 527 | - | ||
| 528 | -sub realloc { | ||
| 529 | - unimpl "realloc() is C-specific, stopped"; | ||
| 530 | -} | ||
| 531 | - | ||
| 532 | -sub srand { | ||
| 533 | - unimpl "srand()"; | ||
| 534 | -} | ||
| 535 | - | ||
| 536 | -sub system { | ||
| 537 | - usage "system(command)" if @_ != 1; | ||
| 538 | - CORE::system($_[0]); | ||
| 539 | -} | ||
| 540 | - | ||
| 541 | -sub memchr { | ||
| 542 | - unimpl "memchr() is C-specific, use index() instead"; | ||
| 543 | -} | ||
| 544 | - | ||
| 545 | -sub memcmp { | ||
| 546 | - unimpl "memcmp() is C-specific, use eq instead"; | ||
| 547 | -} | ||
| 548 | - | ||
| 549 | -sub memcpy { | ||
| 550 | - unimpl "memcpy() is C-specific, use = instead"; | ||
| 551 | -} | ||
| 552 | - | ||
| 553 | -sub memmove { | ||
| 554 | - unimpl "memmove() is C-specific, use = instead"; | ||
| 555 | -} | ||
| 556 | - | ||
| 557 | -sub memset { | ||
| 558 | - unimpl "memset() is C-specific, use x instead"; | ||
| 559 | -} | ||
| 560 | - | ||
| 561 | -sub strcat { | ||
| 562 | - unimpl "strcat() is C-specific, use .= instead"; | ||
| 563 | -} | ||
| 564 | - | ||
| 565 | -sub strchr { | ||
| 566 | - unimpl "strchr() is C-specific, use index() instead"; | ||
| 567 | -} | ||
| 568 | - | ||
| 569 | -sub strcmp { | ||
| 570 | - unimpl "strcmp() is C-specific, use eq instead"; | ||
| 571 | -} | ||
| 572 | - | ||
| 573 | -sub strcpy { | ||
| 574 | - unimpl "strcpy() is C-specific, use = instead"; | ||
| 575 | -} | ||
| 576 | - | ||
| 577 | -sub strcspn { | ||
| 578 | - unimpl "strcspn() is C-specific, use regular expressions instead"; | ||
| 579 | -} | ||
| 580 | - | ||
| 581 | -sub strerror { | ||
| 582 | - usage "strerror(errno)" if @_ != 1; | ||
| 583 | - local $! = $_[0]; | ||
| 584 | - $! . ""; | ||
| 585 | -} | ||
| 586 | - | ||
| 587 | -sub strlen { | ||
| 588 | - unimpl "strlen() is C-specific, use length instead"; | ||
| 589 | -} | ||
| 590 | - | ||
| 591 | -sub strncat { | ||
| 592 | - unimpl "strncat() is C-specific, use .= instead"; | ||
| 593 | -} | ||
| 594 | - | ||
| 595 | -sub strncmp { | ||
| 596 | - unimpl "strncmp() is C-specific, use eq instead"; | ||
| 597 | -} | ||
| 598 | - | ||
| 599 | -sub strncpy { | ||
| 600 | - unimpl "strncpy() is C-specific, use = instead"; | ||
| 601 | -} | ||
| 602 | - | ||
| 603 | -sub strpbrk { | ||
| 604 | - unimpl "strpbrk() is C-specific, stopped"; | ||
| 605 | -} | ||
| 606 | - | ||
| 607 | -sub strrchr { | ||
| 608 | - unimpl "strrchr() is C-specific, use rindex() instead"; | ||
| 609 | -} | ||
| 610 | - | ||
| 611 | -sub strspn { | ||
| 612 | - unimpl "strspn() is C-specific, stopped"; | ||
| 613 | -} | ||
| 614 | - | ||
| 615 | -sub strstr { | ||
| 616 | - usage "strstr(big, little)" if @_ != 2; | ||
| 617 | - CORE::index($_[0], $_[1]); | ||
| 618 | -} | ||
| 619 | - | ||
| 620 | -sub strtok { | ||
| 621 | - unimpl "strtok() is C-specific, stopped"; | ||
| 622 | -} | ||
| 623 | - | ||
| 624 | -sub chmod { | ||
| 625 | - usage "chmod(mode, filename)" if @_ != 2; | ||
| 626 | - CORE::chmod($_[0], $_[1]); | ||
| 627 | -} | ||
| 628 | - | ||
| 629 | -sub fstat { | ||
| 630 | - usage "fstat(fd)" if @_ != 1; | ||
| 631 | - local *TMP; | ||
| 632 | - CORE::open(TMP, "<&$_[0]"); # Gross. | ||
| 633 | - my @l = CORE::stat(TMP); | ||
| 634 | - CORE::close(TMP); | ||
| 635 | - @l; | ||
| 636 | -} | ||
| 637 | - | ||
| 638 | -sub mkdir { | ||
| 639 | - usage "mkdir(directoryname, mode)" if @_ != 2; | ||
| 640 | - CORE::mkdir($_[0], $_[1]); | ||
| 641 | -} | ||
| 642 | - | ||
| 643 | -sub stat { | ||
| 644 | - usage "stat(filename)" if @_ != 1; | ||
| 645 | - CORE::stat($_[0]); | ||
| 646 | -} | ||
| 647 | - | ||
| 648 | -sub umask { | ||
| 649 | - usage "umask(mask)" if @_ != 1; | ||
| 650 | - CORE::umask($_[0]); | ||
| 651 | -} | ||
| 652 | - | ||
| 653 | -sub wait { | ||
| 654 | - usage "wait()" if @_ != 0; | ||
| 655 | - CORE::wait(); | ||
| 656 | -} | ||
| 657 | - | ||
| 658 | -sub waitpid { | ||
| 659 | - usage "waitpid(pid, options)" if @_ != 2; | ||
| 660 | - CORE::waitpid($_[0], $_[1]); | ||
| 661 | -} | ||
| 662 | - | ||
| 663 | -sub gmtime { | ||
| 664 | - usage "gmtime(time)" if @_ != 1; | ||
| 665 | - CORE::gmtime($_[0]); | ||
| 666 | -} | ||
| 667 | - | ||
| 668 | -sub localtime { | ||
| 669 | - usage "localtime(time)" if @_ != 1; | ||
| 670 | - CORE::localtime($_[0]); | ||
| 671 | -} | ||
| 672 | - | ||
| 673 | -sub time { | ||
| 674 | - usage "time()" if @_ != 0; | ||
| 675 | - CORE::time; | ||
| 676 | -} | ||
| 677 | - | ||
| 678 | -sub alarm { | ||
| 679 | - usage "alarm(seconds)" if @_ != 1; | ||
| 680 | - CORE::alarm($_[0]); | ||
| 681 | -} | ||
| 682 | - | ||
| 683 | -sub chdir { | ||
| 684 | - usage "chdir(directory)" if @_ != 1; | ||
| 685 | - CORE::chdir($_[0]); | ||
| 686 | -} | ||
| 687 | - | ||
| 688 | -sub chown { | ||
| 689 | - usage "chown(uid, gid, filename)" if @_ != 3; | ||
| 690 | - CORE::chown($_[0], $_[1], $_[2]); | ||
| 691 | -} | ||
| 692 | - | ||
| 693 | -sub execl { | ||
| 694 | - unimpl "execl() is C-specific, stopped"; | ||
| 695 | -} | ||
| 696 | - | ||
| 697 | -sub execle { | ||
| 698 | - unimpl "execle() is C-specific, stopped"; | ||
| 699 | -} | ||
| 700 | - | ||
| 701 | -sub execlp { | ||
| 702 | - unimpl "execlp() is C-specific, stopped"; | ||
| 703 | -} | ||
| 704 | - | ||
| 705 | -sub execv { | ||
| 706 | - unimpl "execv() is C-specific, stopped"; | ||
| 707 | -} | ||
| 708 | - | ||
| 709 | -sub execve { | ||
| 710 | - unimpl "execve() is C-specific, stopped"; | ||
| 711 | -} | ||
| 712 | - | ||
| 713 | -sub execvp { | ||
| 714 | - unimpl "execvp() is C-specific, stopped"; | ||
| 715 | -} | ||
| 716 | - | ||
| 717 | -sub fork { | ||
| 718 | - usage "fork()" if @_ != 0; | ||
| 719 | - CORE::fork; | ||
| 720 | -} | ||
| 721 | - | ||
| 722 | -sub getegid { | ||
| 723 | - usage "getegid()" if @_ != 0; | ||
| 724 | - $) + 0; | ||
| 725 | -} | ||
| 726 | - | ||
| 727 | -sub geteuid { | ||
| 728 | - usage "geteuid()" if @_ != 0; | ||
| 729 | - $> + 0; | ||
| 730 | -} | ||
| 731 | - | ||
| 732 | -sub getgid { | ||
| 733 | - usage "getgid()" if @_ != 0; | ||
| 734 | - $( + 0; | ||
| 735 | -} | ||
| 736 | - | ||
| 737 | -sub getgroups { | ||
| 738 | - usage "getgroups()" if @_ != 0; | ||
| 739 | - my %seen; | ||
| 740 | - grep(!$seen{$_}++, split(' ', $) )); | ||
| 741 | -} | ||
| 742 | - | ||
| 743 | -sub getlogin { | ||
| 744 | - usage "getlogin()" if @_ != 0; | ||
| 745 | - CORE::getlogin(); | ||
| 746 | -} | ||
| 747 | - | ||
| 748 | -sub getpgrp { | ||
| 749 | - usage "getpgrp()" if @_ != 0; | ||
| 750 | - CORE::getpgrp; | ||
| 751 | -} | ||
| 752 | - | ||
| 753 | -sub getpid { | ||
| 754 | - usage "getpid()" if @_ != 0; | ||
| 755 | - $$; | ||
| 756 | -} | ||
| 757 | - | ||
| 758 | -sub getppid { | ||
| 759 | - usage "getppid()" if @_ != 0; | ||
| 760 | - CORE::getppid; | ||
| 761 | -} | ||
| 762 | - | ||
| 763 | -sub getuid { | ||
| 764 | - usage "getuid()" if @_ != 0; | ||
| 765 | - $<; | ||
| 766 | -} | ||
| 767 | - | ||
| 768 | -sub isatty { | ||
| 769 | - usage "isatty(filehandle)" if @_ != 1; | ||
| 770 | - -t $_[0]; | ||
| 771 | -} | ||
| 772 | - | ||
| 773 | -sub link { | ||
| 774 | - usage "link(oldfilename, newfilename)" if @_ != 2; | ||
| 775 | - CORE::link($_[0], $_[1]); | ||
| 776 | -} | ||
| 777 | - | ||
| 778 | -sub rmdir { | ||
| 779 | - usage "rmdir(directoryname)" if @_ != 1; | ||
| 780 | - CORE::rmdir($_[0]); | ||
| 781 | -} | ||
| 782 | - | ||
| 783 | -sub setbuf { | ||
| 784 | - redef "IO::Handle::setbuf()"; | ||
| 785 | -} | ||
| 786 | - | ||
| 787 | -sub setvbuf { | ||
| 788 | - redef "IO::Handle::setvbuf()"; | ||
| 789 | -} | ||
| 790 | - | ||
| 791 | -sub sleep { | ||
| 792 | - usage "sleep(seconds)" if @_ != 1; | ||
| 793 | - $_[0] - CORE::sleep($_[0]); | ||
| 794 | -} | ||
| 795 | - | ||
| 796 | -sub unlink { | ||
| 797 | - usage "unlink(filename)" if @_ != 1; | ||
| 798 | - CORE::unlink($_[0]); | ||
| 799 | -} | ||
| 800 | - | ||
| 801 | -sub utime { | ||
| 802 | - usage "utime(filename, atime, mtime)" if @_ != 3; | ||
| 803 | - CORE::utime($_[1], $_[2], $_[0]); | ||
| 804 | -} | ||
| 805 | - | ||
| 806 | -sub load_imports { | ||
| 807 | -%EXPORT_TAGS = ( | ||
| 808 | - | ||
| 809 | - assert_h => [qw(assert NDEBUG)], | ||
| 810 | - | ||
| 811 | - ctype_h => [qw(isalnum isalpha iscntrl isdigit isgraph islower | ||
| 812 | - isprint ispunct isspace isupper isxdigit tolower toupper)], | ||
| 813 | - | ||
| 814 | - dirent_h => [], | ||
| 815 | - | ||
| 816 | - errno_h => [qw(E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT | ||
| 817 | - EAGAIN EALREADY EBADF EBUSY ECHILD ECONNABORTED | ||
| 818 | - ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDOM EDQUOT | ||
| 819 | - EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH EINPROGRESS | ||
| 820 | - EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK | ||
| 821 | - EMSGSIZE ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH | ||
| 822 | - ENFILE ENOBUFS ENODEV ENOENT ENOEXEC ENOLCK ENOMEM | ||
| 823 | - ENOPROTOOPT ENOSPC ENOSYS ENOTBLK ENOTCONN ENOTDIR | ||
| 824 | - ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM | ||
| 825 | - EPFNOSUPPORT EPIPE EPROCLIM EPROTONOSUPPORT EPROTOTYPE | ||
| 826 | - ERANGE EREMOTE ERESTART EROFS ESHUTDOWN ESOCKTNOSUPPORT | ||
| 827 | - ESPIPE ESRCH ESTALE ETIMEDOUT ETOOMANYREFS ETXTBSY | ||
| 828 | - EUSERS EWOULDBLOCK EXDEV errno)], | ||
| 829 | - | ||
| 830 | - fcntl_h => [qw(FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK | ||
| 831 | - F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK | ||
| 832 | - O_ACCMODE O_APPEND O_CREAT O_EXCL O_NOCTTY O_NONBLOCK | ||
| 833 | - O_RDONLY O_RDWR O_TRUNC O_WRONLY | ||
| 834 | - creat | ||
| 835 | - SEEK_CUR SEEK_END SEEK_SET | ||
| 836 | - S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU | ||
| 837 | - S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG S_ISUID | ||
| 838 | - S_IWGRP S_IWOTH S_IWUSR)], | ||
| 839 | - | ||
| 840 | - float_h => [qw(DBL_DIG DBL_EPSILON DBL_MANT_DIG | ||
| 841 | - DBL_MAX DBL_MAX_10_EXP DBL_MAX_EXP | ||
| 842 | - DBL_MIN DBL_MIN_10_EXP DBL_MIN_EXP | ||
| 843 | - FLT_DIG FLT_EPSILON FLT_MANT_DIG | ||
| 844 | - FLT_MAX FLT_MAX_10_EXP FLT_MAX_EXP | ||
| 845 | - FLT_MIN FLT_MIN_10_EXP FLT_MIN_EXP | ||
| 846 | - FLT_RADIX FLT_ROUNDS | ||
| 847 | - LDBL_DIG LDBL_EPSILON LDBL_MANT_DIG | ||
| 848 | - LDBL_MAX LDBL_MAX_10_EXP LDBL_MAX_EXP | ||
| 849 | - LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP)], | ||
| 850 | - | ||
| 851 | - grp_h => [], | ||
| 852 | - | ||
| 853 | - limits_h => [qw( ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX | ||
| 854 | - INT_MAX INT_MIN LINK_MAX LONG_MAX LONG_MIN MAX_CANON | ||
| 855 | - MAX_INPUT MB_LEN_MAX NAME_MAX NGROUPS_MAX OPEN_MAX | ||
| 856 | - PATH_MAX PIPE_BUF SCHAR_MAX SCHAR_MIN SHRT_MAX SHRT_MIN | ||
| 857 | - SSIZE_MAX STREAM_MAX TZNAME_MAX UCHAR_MAX UINT_MAX | ||
| 858 | - ULONG_MAX USHRT_MAX _POSIX_ARG_MAX _POSIX_CHILD_MAX | ||
| 859 | - _POSIX_LINK_MAX _POSIX_MAX_CANON _POSIX_MAX_INPUT | ||
| 860 | - _POSIX_NAME_MAX _POSIX_NGROUPS_MAX _POSIX_OPEN_MAX | ||
| 861 | - _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_SSIZE_MAX | ||
| 862 | - _POSIX_STREAM_MAX _POSIX_TZNAME_MAX)], | ||
| 863 | - | ||
| 864 | - locale_h => [qw(LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES | ||
| 865 | - LC_MONETARY LC_NUMERIC LC_TIME NULL | ||
| 866 | - localeconv setlocale)], | ||
| 867 | - | ||
| 868 | - math_h => [qw(HUGE_VAL acos asin atan ceil cosh fabs floor fmod | ||
| 869 | - frexp ldexp log10 modf pow sinh tan tanh)], | ||
| 870 | - | ||
| 871 | - pwd_h => [], | ||
| 872 | - | ||
| 873 | - setjmp_h => [qw(longjmp setjmp siglongjmp sigsetjmp)], | ||
| 874 | - | ||
| 875 | - signal_h => [qw(SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK | ||
| 876 | - SA_RESETHAND SA_RESTART SA_SIGINFO SIGABRT SIGALRM | ||
| 877 | - SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL | ||
| 878 | - SIGPIPE %SIGRT SIGRTMIN SIGRTMAX SIGQUIT SIGSEGV SIGSTOP | ||
| 879 | - SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 | ||
| 880 | - SIG_BLOCK SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK SIG_UNBLOCK | ||
| 881 | - raise sigaction signal sigpending sigprocmask sigsuspend)], | ||
| 882 | - | ||
| 883 | - stdarg_h => [], | ||
| 884 | - | ||
| 885 | - stddef_h => [qw(NULL offsetof)], | ||
| 886 | - | ||
| 887 | - stdio_h => [qw(BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid | ||
| 888 | - L_tmpname NULL SEEK_CUR SEEK_END SEEK_SET | ||
| 889 | - STREAM_MAX TMP_MAX stderr stdin stdout | ||
| 890 | - clearerr fclose fdopen feof ferror fflush fgetc fgetpos | ||
| 891 | - fgets fopen fprintf fputc fputs fread freopen | ||
| 892 | - fscanf fseek fsetpos ftell fwrite getchar gets | ||
| 893 | - perror putc putchar puts remove rewind | ||
| 894 | - scanf setbuf setvbuf sscanf tmpfile tmpnam | ||
| 895 | - ungetc vfprintf vprintf vsprintf)], | ||
| 896 | - | ||
| 897 | - stdlib_h => [qw(EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX NULL RAND_MAX | ||
| 898 | - abort atexit atof atoi atol bsearch calloc div | ||
| 899 | - free getenv labs ldiv malloc mblen mbstowcs mbtowc | ||
| 900 | - qsort realloc strtod strtol strtoul wcstombs wctomb)], | ||
| 901 | - | ||
| 902 | - string_h => [qw(NULL memchr memcmp memcpy memmove memset strcat | ||
| 903 | - strchr strcmp strcoll strcpy strcspn strerror strlen | ||
| 904 | - strncat strncmp strncpy strpbrk strrchr strspn strstr | ||
| 905 | - strtok strxfrm)], | ||
| 906 | - | ||
| 907 | - sys_stat_h => [qw(S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU | ||
| 908 | - S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG | ||
| 909 | - S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR | ||
| 910 | - fstat mkfifo)], | ||
| 911 | - | ||
| 912 | - sys_times_h => [], | ||
| 913 | - | ||
| 914 | - sys_types_h => [], | ||
| 915 | - | ||
| 916 | - sys_utsname_h => [qw(uname)], | ||
| 917 | - | ||
| 918 | - sys_wait_h => [qw(WEXITSTATUS WIFEXITED WIFSIGNALED WIFSTOPPED | ||
| 919 | - WNOHANG WSTOPSIG WTERMSIG WUNTRACED)], | ||
| 920 | - | ||
| 921 | - termios_h => [qw( B0 B110 B1200 B134 B150 B1800 B19200 B200 B2400 | ||
| 922 | - B300 B38400 B4800 B50 B600 B75 B9600 BRKINT CLOCAL | ||
| 923 | - CREAD CS5 CS6 CS7 CS8 CSIZE CSTOPB ECHO ECHOE ECHOK | ||
| 924 | - ECHONL HUPCL ICANON ICRNL IEXTEN IGNBRK IGNCR IGNPAR | ||
| 925 | - INLCR INPCK ISIG ISTRIP IXOFF IXON NCCS NOFLSH OPOST | ||
| 926 | - PARENB PARMRK PARODD TCIFLUSH TCIOFF TCIOFLUSH TCION | ||
| 927 | - TCOFLUSH TCOOFF TCOON TCSADRAIN TCSAFLUSH TCSANOW | ||
| 928 | - TOSTOP VEOF VEOL VERASE VINTR VKILL VMIN VQUIT VSTART | ||
| 929 | - VSTOP VSUSP VTIME | ||
| 930 | - cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcdrain | ||
| 931 | - tcflow tcflush tcgetattr tcsendbreak tcsetattr )], | ||
| 932 | - | ||
| 933 | - time_h => [qw(CLK_TCK CLOCKS_PER_SEC NULL asctime clock ctime | ||
| 934 | - difftime mktime strftime tzset tzname)], | ||
| 935 | - | ||
| 936 | - unistd_h => [qw(F_OK NULL R_OK SEEK_CUR SEEK_END SEEK_SET | ||
| 937 | - STDERR_FILENO STDIN_FILENO STDOUT_FILENO W_OK X_OK | ||
| 938 | - _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON | ||
| 939 | - _PC_MAX_INPUT _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX | ||
| 940 | - _PC_PIPE_BUF _PC_VDISABLE _POSIX_CHOWN_RESTRICTED | ||
| 941 | - _POSIX_JOB_CONTROL _POSIX_NO_TRUNC _POSIX_SAVED_IDS | ||
| 942 | - _POSIX_VDISABLE _POSIX_VERSION _SC_ARG_MAX | ||
| 943 | - _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL | ||
| 944 | - _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_PAGESIZE _SC_SAVED_IDS | ||
| 945 | - _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION | ||
| 946 | - _exit access ctermid cuserid | ||
| 947 | - dup2 dup execl execle execlp execv execve execvp | ||
| 948 | - fpathconf fsync getcwd getegid geteuid getgid getgroups | ||
| 949 | - getpid getuid isatty lseek pathconf pause setgid setpgid | ||
| 950 | - setsid setuid sysconf tcgetpgrp tcsetpgrp ttyname)], | ||
| 951 | - | ||
| 952 | - utime_h => [], | ||
| 953 | - | ||
| 954 | -); | ||
| 955 | - | ||
| 956 | -# Exporter::export_tags(); | ||
| 957 | -{ | ||
| 958 | - # De-duplicate the export list: | ||
| 959 | - my %export; | ||
| 960 | - @export{map {@$_} values %EXPORT_TAGS} = (); | ||
| 961 | - # Doing the de-dup with a temporary hash has the advantage that the SVs in | ||
| 962 | - # @EXPORT are actually shared hash key sacalars, which will save some memory. | ||
| 963 | - push @EXPORT, keys %export; | ||
| 964 | -} | ||
| 965 | - | ||
| 966 | -@EXPORT_OK = qw( | ||
| 967 | - abs | ||
| 968 | - alarm | ||
| 969 | - atan2 | ||
| 970 | - chdir | ||
| 971 | - chmod | ||
| 972 | - chown | ||
| 973 | - close | ||
| 974 | - closedir | ||
| 975 | - cos | ||
| 976 | - exit | ||
| 977 | - exp | ||
| 978 | - fcntl | ||
| 979 | - fileno | ||
| 980 | - fork | ||
| 981 | - getc | ||
| 982 | - getgrgid | ||
| 983 | - getgrnam | ||
| 984 | - getlogin | ||
| 985 | - getpgrp | ||
| 986 | - getppid | ||
| 987 | - getpwnam | ||
| 988 | - getpwuid | ||
| 989 | - gmtime | ||
| 990 | - isatty | ||
| 991 | - kill | ||
| 992 | - lchown | ||
| 993 | - link | ||
| 994 | - localtime | ||
| 995 | - log | ||
| 996 | - mkdir | ||
| 997 | - nice | ||
| 998 | - open | ||
| 999 | - opendir | ||
| 1000 | - pipe | ||
| 1001 | - printf | ||
| 1002 | - rand | ||
| 1003 | - read | ||
| 1004 | - readdir | ||
| 1005 | - rename | ||
| 1006 | - rewinddir | ||
| 1007 | - rmdir | ||
| 1008 | - sin | ||
| 1009 | - sleep | ||
| 1010 | - sprintf | ||
| 1011 | - sqrt | ||
| 1012 | - srand | ||
| 1013 | - stat | ||
| 1014 | - system | ||
| 1015 | - time | ||
| 1016 | - times | ||
| 1017 | - umask | ||
| 1018 | - unlink | ||
| 1019 | - utime | ||
| 1020 | - wait | ||
| 1021 | - waitpid | ||
| 1022 | - write | ||
| 1023 | -); | ||
| 1024 | - | ||
| 1025 | -require Exporter; | ||
| 1026 | -} | ||
| 1027 | - | ||
| 1028 | -package POSIX::SigAction; | ||
| 1029 | - | ||
| 1030 | -sub new { bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0, SAFE => 0}, $_[0] } | ||
| 1031 | -sub handler { $_[0]->{HANDLER} = $_[1] if @_ > 1; $_[0]->{HANDLER} }; | ||
| 1032 | -sub mask { $_[0]->{MASK} = $_[1] if @_ > 1; $_[0]->{MASK} }; | ||
| 1033 | -sub flags { $_[0]->{FLAGS} = $_[1] if @_ > 1; $_[0]->{FLAGS} }; | ||
| 1034 | -sub safe { $_[0]->{SAFE} = $_[1] if @_ > 1; $_[0]->{SAFE} }; | ||
| 1035 | - | ||
| 1036 | -package POSIX::SigRt; | ||
| 1037 | - | ||
| 1038 | - | ||
| 1039 | -sub _init { | ||
| 1040 | - $_SIGRTMIN = &POSIX::SIGRTMIN; | ||
| 1041 | - $_SIGRTMAX = &POSIX::SIGRTMAX; | ||
| 1042 | - $_sigrtn = $_SIGRTMAX - $_SIGRTMIN; | ||
| 1043 | -} | ||
| 1044 | - | ||
| 1045 | -sub _croak { | ||
| 1046 | - &_init unless defined $_sigrtn; | ||
| 1047 | - die "POSIX::SigRt not available" unless defined $_sigrtn && $_sigrtn > 0; | ||
| 1048 | -} | ||
| 1049 | - | ||
| 1050 | -sub _getsig { | ||
| 1051 | - &_croak; | ||
| 1052 | - my $rtsig = $_[0]; | ||
| 1053 | - # Allow (SIGRT)?MIN( + n)?, a common idiom when doing these things in C. | ||
| 1054 | - $rtsig = $_SIGRTMIN + ($1 || 0) | ||
| 1055 | - if $rtsig =~ /^(?:(?:SIG)?RT)?MIN(\s*\+\s*(\d+))?$/; | ||
| 1056 | - return $rtsig; | ||
| 1057 | -} | ||
| 1058 | - | ||
| 1059 | -sub _exist { | ||
| 1060 | - my $rtsig = _getsig($_[1]); | ||
| 1061 | - my $ok = $rtsig >= $_SIGRTMIN && $rtsig <= $_SIGRTMAX; | ||
| 1062 | - ($rtsig, $ok); | ||
| 1063 | -} | ||
| 1064 | - | ||
| 1065 | -sub _check { | ||
| 1066 | - my ($rtsig, $ok) = &_exist; | ||
| 1067 | - die "No POSIX::SigRt signal $_[1] (valid range SIGRTMIN..SIGRTMAX, or $_SIGRTMIN..$_SIGRTMAX)" | ||
| 1068 | - unless $ok; | ||
| 1069 | - return $rtsig; | ||
| 1070 | -} | ||
| 1071 | - | ||
| 1072 | -sub new { | ||
| 1073 | - my ($rtsig, $handler, $flags) = @_; | ||
| 1074 | - my $sigset = POSIX::SigSet->new($rtsig); | ||
| 1075 | - my $sigact = POSIX::SigAction->new($handler, | ||
| 1076 | - $sigset, | ||
| 1077 | - $flags); | ||
| 1078 | - POSIX::sigaction($rtsig, $sigact); | ||
| 1079 | -} | ||
| 1080 | - | ||
| 1081 | -sub EXISTS { &_exist } | ||
| 1082 | -sub FETCH { my $rtsig = &_check; | ||
| 1083 | - my $oa = POSIX::SigAction->new(); | ||
| 1084 | - POSIX::sigaction($rtsig, undef, $oa); | ||
| 1085 | - return $oa->{HANDLER} } | ||
| 1086 | -sub STORE { my $rtsig = &_check; new($rtsig, $_[2], $SIGACTION_FLAGS) } | ||
| 1087 | -sub DELETE { delete $SIG{ &_check } } | ||
| 1088 | -sub CLEAR { &_exist; delete @SIG{ &POSIX::SIGRTMIN .. &POSIX::SIGRTMAX } } | ||
| 1089 | -sub SCALAR { &_croak; $_sigrtn + 1 } | ||
| 1090 | diff --git a/ext/POSIX/POSIX.pod b/ext/POSIX/POSIX.pod | ||
| 1091 | deleted file mode 100644 | ||
| 1092 | index 64852e9..0000000 | ||
| 1093 | --- a/ext/POSIX/POSIX.pod | ||
| 1094 | +++ /dev/null | ||
| 1095 | @@ -1,2218 +0,0 @@ | ||
| 1096 | -=head1 NAME | ||
| 1097 | - | ||
| 1098 | -POSIX - Perl interface to IEEE Std 1003.1 | ||
| 1099 | - | ||
| 1100 | -=head1 SYNOPSIS | ||
| 1101 | - | ||
| 1102 | - use POSIX; | ||
| 1103 | - use POSIX qw(setsid); | ||
| 1104 | - use POSIX qw(:errno_h :fcntl_h); | ||
| 1105 | - | ||
| 1106 | - printf "EINTR is %d\n", EINTR; | ||
| 1107 | - | ||
| 1108 | - $sess_id = POSIX::setsid(); | ||
| 1109 | - | ||
| 1110 | - $fd = POSIX::open($path, O_CREAT|O_EXCL|O_WRONLY, 0644); | ||
| 1111 | - # note: that's a filedescriptor, *NOT* a filehandle | ||
| 1112 | - | ||
| 1113 | -=head1 DESCRIPTION | ||
| 1114 | - | ||
| 1115 | -The POSIX module permits you to access all (or nearly all) the standard | ||
| 1116 | -POSIX 1003.1 identifiers. Many of these identifiers have been given Perl-ish | ||
| 1117 | -interfaces. | ||
| 1118 | - | ||
| 1119 | -I<Everything is exported by default> with the exception of any POSIX | ||
| 1120 | -functions with the same name as a built-in Perl function, such as | ||
| 1121 | -C<abs>, C<alarm>, C<rmdir>, C<write>, etc.., which will be exported | ||
| 1122 | -only if you ask for them explicitly. This is an unfortunate backwards | ||
| 1123 | -compatibility feature. You can stop the exporting by saying C<use | ||
| 1124 | -POSIX ()> and then use the fully qualified names (ie. C<POSIX::SEEK_END>). | ||
| 1125 | - | ||
| 1126 | -This document gives a condensed list of the features available in the POSIX | ||
| 1127 | -module. Consult your operating system's manpages for general information on | ||
| 1128 | -most features. Consult L<perlfunc> for functions which are noted as being | ||
| 1129 | -identical to Perl's builtin functions. | ||
| 1130 | - | ||
| 1131 | -The first section describes POSIX functions from the 1003.1 specification. | ||
| 1132 | -The second section describes some classes for signal objects, TTY objects, | ||
| 1133 | -and other miscellaneous objects. The remaining sections list various | ||
| 1134 | -constants and macros in an organization which roughly follows IEEE Std | ||
| 1135 | -1003.1b-1993. | ||
| 1136 | - | ||
| 1137 | -=head1 NOTE | ||
| 1138 | - | ||
| 1139 | -The POSIX module is probably the most complex Perl module supplied with | ||
| 1140 | -the standard distribution. It incorporates autoloading, namespace games, | ||
| 1141 | -and dynamic loading of code that's in Perl, C, or both. It's a great | ||
| 1142 | -source of wisdom. | ||
| 1143 | - | ||
| 1144 | -=head1 CAVEATS | ||
| 1145 | - | ||
| 1146 | -A few functions are not implemented because they are C specific. If you | ||
| 1147 | -attempt to call these, they will print a message telling you that they | ||
| 1148 | -aren't implemented, and suggest using the Perl equivalent should one | ||
| 1149 | -exist. For example, trying to access the setjmp() call will elicit the | ||
| 1150 | -message "setjmp() is C-specific: use eval {} instead". | ||
| 1151 | - | ||
| 1152 | -Furthermore, some evil vendors will claim 1003.1 compliance, but in fact | ||
| 1153 | -are not so: they will not pass the PCTS (POSIX Compliance Test Suites). | ||
| 1154 | -For example, one vendor may not define EDEADLK, or the semantics of the | ||
| 1155 | -errno values set by open(2) might not be quite right. Perl does not | ||
| 1156 | -attempt to verify POSIX compliance. That means you can currently | ||
| 1157 | -successfully say "use POSIX", and then later in your program you find | ||
| 1158 | -that your vendor has been lax and there's no usable ICANON macro after | ||
| 1159 | -all. This could be construed to be a bug. | ||
| 1160 | - | ||
| 1161 | -=head1 FUNCTIONS | ||
| 1162 | - | ||
| 1163 | -=over 8 | ||
| 1164 | - | ||
| 1165 | -=item _exit | ||
| 1166 | - | ||
| 1167 | -This is identical to the C function C<_exit()>. It exits the program | ||
| 1168 | -immediately which means among other things buffered I/O is B<not> flushed. | ||
| 1169 | - | ||
| 1170 | -Note that when using threads and in Linux this is B<not> a good way to | ||
| 1171 | -exit a thread because in Linux processes and threads are kind of the | ||
| 1172 | -same thing (Note: while this is the situation in early 2003 there are | ||
| 1173 | -projects under way to have threads with more POSIXly semantics in Linux). | ||
| 1174 | -If you want not to return from a thread, detach the thread. | ||
| 1175 | - | ||
| 1176 | -=item abort | ||
| 1177 | - | ||
| 1178 | -This is identical to the C function C<abort()>. It terminates the | ||
| 1179 | -process with a C<SIGABRT> signal unless caught by a signal handler or | ||
| 1180 | -if the handler does not return normally (it e.g. does a C<longjmp>). | ||
| 1181 | - | ||
| 1182 | -=item abs | ||
| 1183 | - | ||
| 1184 | -This is identical to Perl's builtin C<abs()> function, returning | ||
| 1185 | -the absolute value of its numerical argument. | ||
| 1186 | - | ||
| 1187 | -=item access | ||
| 1188 | - | ||
| 1189 | -Determines the accessibility of a file. | ||
| 1190 | - | ||
| 1191 | - if( POSIX::access( "/", &POSIX::R_OK ) ){ | ||
| 1192 | - print "have read permission\n"; | ||
| 1193 | - } | ||
| 1194 | - | ||
| 1195 | -Returns C<undef> on failure. Note: do not use C<access()> for | ||
| 1196 | -security purposes. Between the C<access()> call and the operation | ||
| 1197 | -you are preparing for the permissions might change: a classic | ||
| 1198 | -I<race condition>. | ||
| 1199 | - | ||
| 1200 | -=item acos | ||
| 1201 | - | ||
| 1202 | -This is identical to the C function C<acos()>, returning | ||
| 1203 | -the arcus cosine of its numerical argument. See also L<Math::Trig>. | ||
| 1204 | - | ||
| 1205 | -=item alarm | ||
| 1206 | - | ||
| 1207 | -This is identical to Perl's builtin C<alarm()> function, | ||
| 1208 | -either for arming or disarming the C<SIGARLM> timer. | ||
| 1209 | - | ||
| 1210 | -=item asctime | ||
| 1211 | - | ||
| 1212 | -This is identical to the C function C<asctime()>. It returns | ||
| 1213 | -a string of the form | ||
| 1214 | - | ||
| 1215 | - "Fri Jun 2 18:22:13 2000\n\0" | ||
| 1216 | - | ||
| 1217 | -and it is called thusly | ||
| 1218 | - | ||
| 1219 | - $asctime = asctime($sec, $min, $hour, $mday, $mon, $year, | ||
| 1220 | - $wday, $yday, $isdst); | ||
| 1221 | - | ||
| 1222 | -The C<$mon> is zero-based: January equals C<0>. The C<$year> is | ||
| 1223 | -1900-based: 2001 equals C<101>. C<$wday> and C<$yday> default to zero | ||
| 1224 | -(and are usually ignored anyway), and C<$isdst> defaults to -1. | ||
| 1225 | - | ||
| 1226 | -=item asin | ||
| 1227 | - | ||
| 1228 | -This is identical to the C function C<asin()>, returning | ||
| 1229 | -the arcus sine of its numerical argument. See also L<Math::Trig>. | ||
| 1230 | - | ||
| 1231 | -=item assert | ||
| 1232 | - | ||
| 1233 | -Unimplemented, but you can use L<perlfunc/die> and the L<Carp> module | ||
| 1234 | -to achieve similar things. | ||
| 1235 | - | ||
| 1236 | -=item atan | ||
| 1237 | - | ||
| 1238 | -This is identical to the C function C<atan()>, returning the | ||
| 1239 | -arcus tangent of its numerical argument. See also L<Math::Trig>. | ||
| 1240 | - | ||
| 1241 | -=item atan2 | ||
| 1242 | - | ||
| 1243 | -This is identical to Perl's builtin C<atan2()> function, returning | ||
| 1244 | -the arcus tangent defined by its two numerical arguments, the I<y> | ||
| 1245 | -coordinate and the I<x> coordinate. See also L<Math::Trig>. | ||
| 1246 | - | ||
| 1247 | -=item atexit | ||
| 1248 | - | ||
| 1249 | -atexit() is C-specific: use C<END {}> instead, see L<perlsub>. | ||
| 1250 | - | ||
| 1251 | -=item atof | ||
| 1252 | - | ||
| 1253 | -atof() is C-specific. Perl converts strings to numbers transparently. | ||
| 1254 | -If you need to force a scalar to a number, add a zero to it. | ||
| 1255 | - | ||
| 1256 | -=item atoi | ||
| 1257 | - | ||
| 1258 | -atoi() is C-specific. Perl converts strings to numbers transparently. | ||
| 1259 | -If you need to force a scalar to a number, add a zero to it. | ||
| 1260 | -If you need to have just the integer part, see L<perlfunc/int>. | ||
| 1261 | - | ||
| 1262 | -=item atol | ||
| 1263 | - | ||
| 1264 | -atol() is C-specific. Perl converts strings to numbers transparently. | ||
| 1265 | -If you need to force a scalar to a number, add a zero to it. | ||
| 1266 | -If you need to have just the integer part, see L<perlfunc/int>. | ||
| 1267 | - | ||
| 1268 | -=item bsearch | ||
| 1269 | - | ||
| 1270 | -bsearch() not supplied. For doing binary search on wordlists, | ||
| 1271 | -see L<Search::Dict>. | ||
| 1272 | - | ||
| 1273 | -=item calloc | ||
| 1274 | - | ||
| 1275 | -calloc() is C-specific. Perl does memory management transparently. | ||
| 1276 | - | ||
| 1277 | -=item ceil | ||
| 1278 | - | ||
| 1279 | -This is identical to the C function C<ceil()>, returning the smallest | ||
| 1280 | -integer value greater than or equal to the given numerical argument. | ||
| 1281 | - | ||
| 1282 | -=item chdir | ||
| 1283 | - | ||
| 1284 | -This is identical to Perl's builtin C<chdir()> function, allowing | ||
| 1285 | -one to change the working (default) directory, see L<perlfunc/chdir>. | ||
| 1286 | - | ||
| 1287 | -=item chmod | ||
| 1288 | - | ||
| 1289 | -This is identical to Perl's builtin C<chmod()> function, allowing | ||
| 1290 | -one to change file and directory permissions, see L<perlfunc/chmod>. | ||
| 1291 | - | ||
| 1292 | -=item chown | ||
| 1293 | - | ||
| 1294 | -This is identical to Perl's builtin C<chown()> function, allowing one | ||
| 1295 | -to change file and directory owners and groups, see L<perlfunc/chown>. | ||
| 1296 | - | ||
| 1297 | -=item clearerr | ||
| 1298 | - | ||
| 1299 | -Use the method C<IO::Handle::clearerr()> instead, to reset the error | ||
| 1300 | -state (if any) and EOF state (if any) of the given stream. | ||
| 1301 | - | ||
| 1302 | -=item clock | ||
| 1303 | - | ||
| 1304 | -This is identical to the C function C<clock()>, returning the | ||
| 1305 | -amount of spent processor time in microseconds. | ||
| 1306 | - | ||
| 1307 | -=item close | ||
| 1308 | - | ||
| 1309 | -Close the file. This uses file descriptors such as those obtained by calling | ||
| 1310 | -C<POSIX::open>. | ||
| 1311 | - | ||
| 1312 | - $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); | ||
| 1313 | - POSIX::close( $fd ); | ||
| 1314 | - | ||
| 1315 | -Returns C<undef> on failure. | ||
| 1316 | - | ||
| 1317 | -See also L<perlfunc/close>. | ||
| 1318 | - | ||
| 1319 | -=item closedir | ||
| 1320 | - | ||
| 1321 | -This is identical to Perl's builtin C<closedir()> function for closing | ||
| 1322 | -a directory handle, see L<perlfunc/closedir>. | ||
| 1323 | - | ||
| 1324 | -=item cos | ||
| 1325 | - | ||
| 1326 | -This is identical to Perl's builtin C<cos()> function, for returning | ||
| 1327 | -the cosine of its numerical argument, see L<perlfunc/cos>. | ||
| 1328 | -See also L<Math::Trig>. | ||
| 1329 | - | ||
| 1330 | -=item cosh | ||
| 1331 | - | ||
| 1332 | -This is identical to the C function C<cosh()>, for returning | ||
| 1333 | -the hyperbolic cosine of its numeric argument. See also L<Math::Trig>. | ||
| 1334 | - | ||
| 1335 | -=item creat | ||
| 1336 | - | ||
| 1337 | -Create a new file. This returns a file descriptor like the ones returned by | ||
| 1338 | -C<POSIX::open>. Use C<POSIX::close> to close the file. | ||
| 1339 | - | ||
| 1340 | - $fd = POSIX::creat( "foo", 0611 ); | ||
| 1341 | - POSIX::close( $fd ); | ||
| 1342 | - | ||
| 1343 | -See also L<perlfunc/sysopen> and its C<O_CREAT> flag. | ||
| 1344 | - | ||
| 1345 | -=item ctermid | ||
| 1346 | - | ||
| 1347 | -Generates the path name for the controlling terminal. | ||
| 1348 | - | ||
| 1349 | - $path = POSIX::ctermid(); | ||
| 1350 | - | ||
| 1351 | -=item ctime | ||
| 1352 | - | ||
| 1353 | -This is identical to the C function C<ctime()> and equivalent | ||
| 1354 | -to C<asctime(localtime(...))>, see L</asctime> and L</localtime>. | ||
| 1355 | - | ||
| 1356 | -=item cuserid | ||
| 1357 | - | ||
| 1358 | -Get the login name of the owner of the current process. | ||
| 1359 | - | ||
| 1360 | - $name = POSIX::cuserid(); | ||
| 1361 | - | ||
| 1362 | -=item difftime | ||
| 1363 | - | ||
| 1364 | -This is identical to the C function C<difftime()>, for returning | ||
| 1365 | -the time difference (in seconds) between two times (as returned | ||
| 1366 | -by C<time()>), see L</time>. | ||
| 1367 | - | ||
| 1368 | -=item div | ||
| 1369 | - | ||
| 1370 | -div() is C-specific, use L<perlfunc/int> on the usual C</> division and | ||
| 1371 | -the modulus C<%>. | ||
| 1372 | - | ||
| 1373 | -=item dup | ||
| 1374 | - | ||
| 1375 | -This is similar to the C function C<dup()>, for duplicating a file | ||
| 1376 | -descriptor. | ||
| 1377 | - | ||
| 1378 | -This uses file descriptors such as those obtained by calling | ||
| 1379 | -C<POSIX::open>. | ||
| 1380 | - | ||
| 1381 | -Returns C<undef> on failure. | ||
| 1382 | - | ||
| 1383 | -=item dup2 | ||
| 1384 | - | ||
| 1385 | -This is similar to the C function C<dup2()>, for duplicating a file | ||
| 1386 | -descriptor to an another known file descriptor. | ||
| 1387 | - | ||
| 1388 | -This uses file descriptors such as those obtained by calling | ||
| 1389 | -C<POSIX::open>. | ||
| 1390 | - | ||
| 1391 | -Returns C<undef> on failure. | ||
| 1392 | - | ||
| 1393 | -=item errno | ||
| 1394 | - | ||
| 1395 | -Returns the value of errno. | ||
| 1396 | - | ||
| 1397 | - $errno = POSIX::errno(); | ||
| 1398 | - | ||
| 1399 | -This identical to the numerical values of the C<$!>, see L<perlvar/$ERRNO>. | ||
| 1400 | - | ||
| 1401 | -=item execl | ||
| 1402 | - | ||
| 1403 | -execl() is C-specific, see L<perlfunc/exec>. | ||
| 1404 | - | ||
| 1405 | -=item execle | ||
| 1406 | - | ||
| 1407 | -execle() is C-specific, see L<perlfunc/exec>. | ||
| 1408 | - | ||
| 1409 | -=item execlp | ||
| 1410 | - | ||
| 1411 | -execlp() is C-specific, see L<perlfunc/exec>. | ||
| 1412 | - | ||
| 1413 | -=item execv | ||
| 1414 | - | ||
| 1415 | -execv() is C-specific, see L<perlfunc/exec>. | ||
| 1416 | - | ||
| 1417 | -=item execve | ||
| 1418 | - | ||
| 1419 | -execve() is C-specific, see L<perlfunc/exec>. | ||
| 1420 | - | ||
| 1421 | -=item execvp | ||
| 1422 | - | ||
| 1423 | -execvp() is C-specific, see L<perlfunc/exec>. | ||
| 1424 | - | ||
| 1425 | -=item exit | ||
| 1426 | - | ||
| 1427 | -This is identical to Perl's builtin C<exit()> function for exiting the | ||
| 1428 | -program, see L<perlfunc/exit>. | ||
| 1429 | - | ||
| 1430 | -=item exp | ||
| 1431 | - | ||
| 1432 | -This is identical to Perl's builtin C<exp()> function for | ||
| 1433 | -returning the exponent (I<e>-based) of the numerical argument, | ||
| 1434 | -see L<perlfunc/exp>. | ||
| 1435 | - | ||
| 1436 | -=item fabs | ||
| 1437 | - | ||
| 1438 | -This is identical to Perl's builtin C<abs()> function for returning | ||
| 1439 | -the absolute value of the numerical argument, see L<perlfunc/abs>. | ||
| 1440 | - | ||
| 1441 | -=item fclose | ||
| 1442 | - | ||
| 1443 | -Use method C<IO::Handle::close()> instead, or see L<perlfunc/close>. | ||
| 1444 | - | ||
| 1445 | -=item fcntl | ||
| 1446 | - | ||
| 1447 | -This is identical to Perl's builtin C<fcntl()> function, | ||
| 1448 | -see L<perlfunc/fcntl>. | ||
| 1449 | - | ||
| 1450 | -=item fdopen | ||
| 1451 | - | ||
| 1452 | -Use method C<IO::Handle::new_from_fd()> instead, or see L<perlfunc/open>. | ||
| 1453 | - | ||
| 1454 | -=item feof | ||
| 1455 | - | ||
| 1456 | -Use method C<IO::Handle::eof()> instead, or see L<perlfunc/eof>. | ||
| 1457 | - | ||
| 1458 | -=item ferror | ||
| 1459 | - | ||
| 1460 | -Use method C<IO::Handle::error()> instead. | ||
| 1461 | - | ||
| 1462 | -=item fflush | ||
| 1463 | - | ||
| 1464 | -Use method C<IO::Handle::flush()> instead. | ||
| 1465 | -See also L<perlvar/$OUTPUT_AUTOFLUSH>. | ||
| 1466 | - | ||
| 1467 | -=item fgetc | ||
| 1468 | - | ||
| 1469 | -Use method C<IO::Handle::getc()> instead, or see L<perlfunc/read>. | ||
| 1470 | - | ||
| 1471 | -=item fgetpos | ||
| 1472 | - | ||
| 1473 | -Use method C<IO::Seekable::getpos()> instead, or see L<L/seek>. | ||
| 1474 | - | ||
| 1475 | -=item fgets | ||
| 1476 | - | ||
| 1477 | -Use method C<IO::Handle::gets()> instead. Similar to E<lt>E<gt>, also known | ||
| 1478 | -as L<perlfunc/readline>. | ||
| 1479 | - | ||
| 1480 | -=item fileno | ||
| 1481 | - | ||
| 1482 | -Use method C<IO::Handle::fileno()> instead, or see L<perlfunc/fileno>. | ||
| 1483 | - | ||
| 1484 | -=item floor | ||
| 1485 | - | ||
| 1486 | -This is identical to the C function C<floor()>, returning the largest | ||
| 1487 | -integer value less than or equal to the numerical argument. | ||
| 1488 | - | ||
| 1489 | -=item fmod | ||
| 1490 | - | ||
| 1491 | -This is identical to the C function C<fmod()>. | ||
| 1492 | - | ||
| 1493 | - $r = fmod($x, $y); | ||
| 1494 | - | ||
| 1495 | -It returns the remainder C<$r = $x - $n*$y>, where C<$n = trunc($x/$y)>. | ||
| 1496 | -The C<$r> has the same sign as C<$x> and magnitude (absolute value) | ||
| 1497 | -less than the magnitude of C<$y>. | ||
| 1498 | - | ||
| 1499 | -=item fopen | ||
| 1500 | - | ||
| 1501 | -Use method C<IO::File::open()> instead, or see L<perlfunc/open>. | ||
| 1502 | - | ||
| 1503 | -=item fork | ||
| 1504 | - | ||
| 1505 | -This is identical to Perl's builtin C<fork()> function | ||
| 1506 | -for duplicating the current process, see L<perlfunc/fork> | ||
| 1507 | -and L<perlfork> if you are in Windows. | ||
| 1508 | - | ||
| 1509 | -=item fpathconf | ||
| 1510 | - | ||
| 1511 | -Retrieves the value of a configurable limit on a file or directory. This | ||
| 1512 | -uses file descriptors such as those obtained by calling C<POSIX::open>. | ||
| 1513 | - | ||
| 1514 | -The following will determine the maximum length of the longest allowable | ||
| 1515 | -pathname on the filesystem which holds C</var/foo>. | ||
| 1516 | - | ||
| 1517 | - $fd = POSIX::open( "/var/foo", &POSIX::O_RDONLY ); | ||
| 1518 | - $path_max = POSIX::fpathconf( $fd, &POSIX::_PC_PATH_MAX ); | ||
| 1519 | - | ||
| 1520 | -Returns C<undef> on failure. | ||
| 1521 | - | ||
| 1522 | -=item fprintf | ||
| 1523 | - | ||
| 1524 | -fprintf() is C-specific, see L<perlfunc/printf> instead. | ||
| 1525 | - | ||
| 1526 | -=item fputc | ||
| 1527 | - | ||
| 1528 | -fputc() is C-specific, see L<perlfunc/print> instead. | ||
| 1529 | - | ||
| 1530 | -=item fputs | ||
| 1531 | - | ||
| 1532 | -fputs() is C-specific, see L<perlfunc/print> instead. | ||
| 1533 | - | ||
| 1534 | -=item fread | ||
| 1535 | - | ||
| 1536 | -fread() is C-specific, see L<perlfunc/read> instead. | ||
| 1537 | - | ||
| 1538 | -=item free | ||
| 1539 | - | ||
| 1540 | -free() is C-specific. Perl does memory management transparently. | ||
| 1541 | - | ||
| 1542 | -=item freopen | ||
| 1543 | - | ||
| 1544 | -freopen() is C-specific, see L<perlfunc/open> instead. | ||
| 1545 | - | ||
| 1546 | -=item frexp | ||
| 1547 | - | ||
| 1548 | -Return the mantissa and exponent of a floating-point number. | ||
| 1549 | - | ||
| 1550 | - ($mantissa, $exponent) = POSIX::frexp( 1.234e56 ); | ||
| 1551 | - | ||
| 1552 | -=item fscanf | ||
| 1553 | - | ||
| 1554 | -fscanf() is C-specific, use E<lt>E<gt> and regular expressions instead. | ||
| 1555 | - | ||
| 1556 | -=item fseek | ||
| 1557 | - | ||
| 1558 | -Use method C<IO::Seekable::seek()> instead, or see L<perlfunc/seek>. | ||
| 1559 | - | ||
| 1560 | -=item fsetpos | ||
| 1561 | - | ||
| 1562 | -Use method C<IO::Seekable::setpos()> instead, or seek L<perlfunc/seek>. | ||
| 1563 | - | ||
| 1564 | -=item fstat | ||
| 1565 | - | ||
| 1566 | -Get file status. This uses file descriptors such as those obtained by | ||
| 1567 | -calling C<POSIX::open>. The data returned is identical to the data from | ||
| 1568 | -Perl's builtin C<stat> function. | ||
| 1569 | - | ||
| 1570 | - $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); | ||
| 1571 | - @stats = POSIX::fstat( $fd ); | ||
| 1572 | - | ||
| 1573 | -=item fsync | ||
| 1574 | - | ||
| 1575 | -Use method C<IO::Handle::sync()> instead. | ||
| 1576 | - | ||
| 1577 | -=item ftell | ||
| 1578 | - | ||
| 1579 | -Use method C<IO::Seekable::tell()> instead, or see L<perlfunc/tell>. | ||
| 1580 | - | ||
| 1581 | -=item fwrite | ||
| 1582 | - | ||
| 1583 | -fwrite() is C-specific, see L<perlfunc/print> instead. | ||
| 1584 | - | ||
| 1585 | -=item getc | ||
| 1586 | - | ||
| 1587 | -This is identical to Perl's builtin C<getc()> function, | ||
| 1588 | -see L<perlfunc/getc>. | ||
| 1589 | - | ||
| 1590 | -=item getchar | ||
| 1591 | - | ||
| 1592 | -Returns one character from STDIN. Identical to Perl's C<getc()>, | ||
| 1593 | -see L<perlfunc/getc>. | ||
| 1594 | - | ||
| 1595 | -=item getcwd | ||
| 1596 | - | ||
| 1597 | -Returns the name of the current working directory. | ||
| 1598 | -See also L<Cwd>. | ||
| 1599 | - | ||
| 1600 | -=item getegid | ||
| 1601 | - | ||
| 1602 | -Returns the effective group identifier. Similar to Perl' s builtin | ||
| 1603 | -variable C<$(>, see L<perlvar/$EGID>. | ||
| 1604 | - | ||
| 1605 | -=item getenv | ||
| 1606 | - | ||
| 1607 | -Returns the value of the specified environment variable. | ||
| 1608 | -The same information is available through the C<%ENV> array. | ||
| 1609 | - | ||
| 1610 | -=item geteuid | ||
| 1611 | - | ||
| 1612 | -Returns the effective user identifier. Identical to Perl's builtin C<$E<gt>> | ||
| 1613 | -variable, see L<perlvar/$EUID>. | ||
| 1614 | - | ||
| 1615 | -=item getgid | ||
| 1616 | - | ||
| 1617 | -Returns the user's real group identifier. Similar to Perl's builtin | ||
| 1618 | -variable C<$)>, see L<perlvar/$GID>. | ||
| 1619 | - | ||
| 1620 | -=item getgrgid | ||
| 1621 | - | ||
| 1622 | -This is identical to Perl's builtin C<getgrgid()> function for | ||
| 1623 | -returning group entries by group identifiers, see | ||
| 1624 | -L<perlfunc/getgrgid>. | ||
| 1625 | - | ||
| 1626 | -=item getgrnam | ||
| 1627 | - | ||
| 1628 | -This is identical to Perl's builtin C<getgrnam()> function for | ||
| 1629 | -returning group entries by group names, see L<perlfunc/getgrnam>. | ||
| 1630 | - | ||
| 1631 | -=item getgroups | ||
| 1632 | - | ||
| 1633 | -Returns the ids of the user's supplementary groups. Similar to Perl's | ||
| 1634 | -builtin variable C<$)>, see L<perlvar/$GID>. | ||
| 1635 | - | ||
| 1636 | -=item getlogin | ||
| 1637 | - | ||
| 1638 | -This is identical to Perl's builtin C<getlogin()> function for | ||
| 1639 | -returning the user name associated with the current session, see | ||
| 1640 | -L<perlfunc/getlogin>. | ||
| 1641 | - | ||
| 1642 | -=item getpgrp | ||
| 1643 | - | ||
| 1644 | -This is identical to Perl's builtin C<getpgrp()> function for | ||
| 1645 | -returning the process group identifier of the current process, see | ||
| 1646 | -L<perlfunc/getpgrp>. | ||
| 1647 | - | ||
| 1648 | -=item getpid | ||
| 1649 | - | ||
| 1650 | -Returns the process identifier. Identical to Perl's builtin | ||
| 1651 | -variable C<$$>, see L<perlvar/$PID>. | ||
| 1652 | - | ||
| 1653 | -=item getppid | ||
| 1654 | - | ||
| 1655 | -This is identical to Perl's builtin C<getppid()> function for | ||
| 1656 | -returning the process identifier of the parent process of the current | ||
| 1657 | -process , see L<perlfunc/getppid>. | ||
| 1658 | - | ||
| 1659 | -=item getpwnam | ||
| 1660 | - | ||
| 1661 | -This is identical to Perl's builtin C<getpwnam()> function for | ||
| 1662 | -returning user entries by user names, see L<perlfunc/getpwnam>. | ||
| 1663 | - | ||
| 1664 | -=item getpwuid | ||
| 1665 | - | ||
| 1666 | -This is identical to Perl's builtin C<getpwuid()> function for | ||
| 1667 | -returning user entries by user identifiers, see L<perlfunc/getpwuid>. | ||
| 1668 | - | ||
| 1669 | -=item gets | ||
| 1670 | - | ||
| 1671 | -Returns one line from C<STDIN>, similar to E<lt>E<gt>, also known | ||
| 1672 | -as the C<readline()> function, see L<perlfunc/readline>. | ||
| 1673 | - | ||
| 1674 | -B<NOTE>: if you have C programs that still use C<gets()>, be very | ||
| 1675 | -afraid. The C<gets()> function is a source of endless grief because | ||
| 1676 | -it has no buffer overrun checks. It should B<never> be used. The | ||
| 1677 | -C<fgets()> function should be preferred instead. | ||
| 1678 | - | ||
| 1679 | -=item getuid | ||
| 1680 | - | ||
| 1681 | -Returns the user's identifier. Identical to Perl's builtin C<$E<lt>> variable, | ||
| 1682 | -see L<perlvar/$UID>. | ||
| 1683 | - | ||
| 1684 | -=item gmtime | ||
| 1685 | - | ||
| 1686 | -This is identical to Perl's builtin C<gmtime()> function for | ||
| 1687 | -converting seconds since the epoch to a date in Greenwich Mean Time, | ||
| 1688 | -see L<perlfunc/gmtime>. | ||
| 1689 | - | ||
| 1690 | -=item isalnum | ||
| 1691 | - | ||
| 1692 | -This is identical to the C function, except that it can apply to a | ||
| 1693 | -single character or to a whole string. Note that locale settings may | ||
| 1694 | -affect what characters are considered C<isalnum>. Does not work on | ||
| 1695 | -Unicode characters code point 256 or higher. Consider using regular | ||
| 1696 | -expressions and the C</[[:alnum:]]/> construct instead, or possibly | ||
| 1697 | -the C</\w/> construct. | ||
| 1698 | - | ||
| 1699 | -=item isalpha | ||
| 1700 | - | ||
| 1701 | -This is identical to the C function, except that it can apply to | ||
| 1702 | -a single character or to a whole string. Note that locale settings | ||
| 1703 | -may affect what characters are considered C<isalpha>. Does not work | ||
| 1704 | -on Unicode characters code point 256 or higher. Consider using regular | ||
| 1705 | -expressions and the C</[[:alpha:]]/> construct instead. | ||
| 1706 | - | ||
| 1707 | -=item isatty | ||
| 1708 | - | ||
| 1709 | -Returns a boolean indicating whether the specified filehandle is connected | ||
| 1710 | -to a tty. Similar to the C<-t> operator, see L<perlfunc/-X>. | ||
| 1711 | - | ||
| 1712 | -=item iscntrl | ||
| 1713 | - | ||
| 1714 | -This is identical to the C function, except that it can apply to | ||
| 1715 | -a single character or to a whole string. Note that locale settings | ||
| 1716 | -may affect what characters are considered C<iscntrl>. Does not work | ||
| 1717 | -on Unicode characters code point 256 or higher. Consider using regular | ||
| 1718 | -expressions and the C</[[:cntrl:]]/> construct instead. | ||
| 1719 | - | ||
| 1720 | -=item isdigit | ||
| 1721 | - | ||
| 1722 | -This is identical to the C function, except that it can apply to | ||
| 1723 | -a single character or to a whole string. Note that locale settings | ||
| 1724 | -may affect what characters are considered C<isdigit> (unlikely, but | ||
| 1725 | -still possible). Does not work on Unicode characters code point 256 | ||
| 1726 | -or higher. Consider using regular expressions and the C</[[:digit:]]/> | ||
| 1727 | -construct instead, or the C</\d/> construct. | ||
| 1728 | - | ||
| 1729 | -=item isgraph | ||
| 1730 | - | ||
| 1731 | -This is identical to the C function, except that it can apply to | ||
| 1732 | -a single character or to a whole string. Note that locale settings | ||
| 1733 | -may affect what characters are considered C<isgraph>. Does not work | ||
| 1734 | -on Unicode characters code point 256 or higher. Consider using regular | ||
| 1735 | -expressions and the C</[[:graph:]]/> construct instead. | ||
| 1736 | - | ||
| 1737 | -=item islower | ||
| 1738 | - | ||
| 1739 | -This is identical to the C function, except that it can apply to | ||
| 1740 | -a single character or to a whole string. Note that locale settings | ||
| 1741 | -may affect what characters are considered C<islower>. Does not work | ||
| 1742 | -on Unicode characters code point 256 or higher. Consider using regular | ||
| 1743 | -expressions and the C</[[:lower:]]/> construct instead. Do B<not> use | ||
| 1744 | -C</[a-z]/>. | ||
| 1745 | - | ||
| 1746 | -=item isprint | ||
| 1747 | - | ||
| 1748 | -This is identical to the C function, except that it can apply to | ||
| 1749 | -a single character or to a whole string. Note that locale settings | ||
| 1750 | -may affect what characters are considered C<isprint>. Does not work | ||
| 1751 | -on Unicode characters code point 256 or higher. Consider using regular | ||
| 1752 | -expressions and the C</[[:print:]]/> construct instead. | ||
| 1753 | - | ||
| 1754 | -=item ispunct | ||
| 1755 | - | ||
| 1756 | -This is identical to the C function, except that it can apply to | ||
| 1757 | -a single character or to a whole string. Note that locale settings | ||
| 1758 | -may affect what characters are considered C<ispunct>. Does not work | ||
| 1759 | -on Unicode characters code point 256 or higher. Consider using regular | ||
| 1760 | -expressions and the C</[[:punct:]]/> construct instead. | ||
| 1761 | - | ||
| 1762 | -=item isspace | ||
| 1763 | - | ||
| 1764 | -This is identical to the C function, except that it can apply to | ||
| 1765 | -a single character or to a whole string. Note that locale settings | ||
| 1766 | -may affect what characters are considered C<isspace>. Does not work | ||
| 1767 | -on Unicode characters code point 256 or higher. Consider using regular | ||
| 1768 | -expressions and the C</[[:space:]]/> construct instead, or the C</\s/> | ||
| 1769 | -construct. (Note that C</\s/> and C</[[:space:]]/> are slightly | ||
| 1770 | -different in that C</[[:space:]]/> can normally match a vertical tab, | ||
| 1771 | -while C</\s/> does not.) | ||
| 1772 | - | ||
| 1773 | -=item isupper | ||
| 1774 | - | ||
| 1775 | -This is identical to the C function, except that it can apply to | ||
| 1776 | -a single character or to a whole string. Note that locale settings | ||
| 1777 | -may affect what characters are considered C<isupper>. Does not work | ||
| 1778 | -on Unicode characters code point 256 or higher. Consider using regular | ||
| 1779 | -expressions and the C</[[:upper:]]/> construct instead. Do B<not> use | ||
| 1780 | -C</[A-Z]/>. | ||
| 1781 | - | ||
| 1782 | -=item isxdigit | ||
| 1783 | - | ||
| 1784 | -This is identical to the C function, except that it can apply to a single | ||
| 1785 | -character or to a whole string. Note that locale settings may affect what | ||
| 1786 | -characters are considered C<isxdigit> (unlikely, but still possible). | ||
| 1787 | -Does not work on Unicode characters code point 256 or higher. | ||
| 1788 | -Consider using regular expressions and the C</[[:xdigit:]]/> | ||
| 1789 | -construct instead, or simply C</[0-9a-f]/i>. | ||
| 1790 | - | ||
| 1791 | -=item kill | ||
| 1792 | - | ||
| 1793 | -This is identical to Perl's builtin C<kill()> function for sending | ||
| 1794 | -signals to processes (often to terminate them), see L<perlfunc/kill>. | ||
| 1795 | - | ||
| 1796 | -=item labs | ||
| 1797 | - | ||
| 1798 | -(For returning absolute values of long integers.) | ||
| 1799 | -labs() is C-specific, see L<perlfunc/abs> instead. | ||
| 1800 | - | ||
| 1801 | -=item lchown | ||
| 1802 | - | ||
| 1803 | -This is identical to the C function, except the order of arguments is | ||
| 1804 | -consistent with Perl's builtin C<chown()> with the added restriction | ||
| 1805 | -of only one path, not an list of paths. Does the same thing as the | ||
| 1806 | -C<chown()> function but changes the owner of a symbolic link instead | ||
| 1807 | -of the file the symbolic link points to. | ||
| 1808 | - | ||
| 1809 | -=item ldexp | ||
| 1810 | - | ||
| 1811 | -This is identical to the C function C<ldexp()> | ||
| 1812 | -for multiplying floating point numbers with powers of two. | ||
| 1813 | - | ||
| 1814 | - $x_quadrupled = POSIX::ldexp($x, 2); | ||
| 1815 | - | ||
| 1816 | -=item ldiv | ||
| 1817 | - | ||
| 1818 | -(For computing dividends of long integers.) | ||
| 1819 | -ldiv() is C-specific, use C</> and C<int()> instead. | ||
| 1820 | - | ||
| 1821 | -=item link | ||
| 1822 | - | ||
| 1823 | -This is identical to Perl's builtin C<link()> function | ||
| 1824 | -for creating hard links into files, see L<perlfunc/link>. | ||
| 1825 | - | ||
| 1826 | -=item localeconv | ||
| 1827 | - | ||
| 1828 | -Get numeric formatting information. Returns a reference to a hash | ||
| 1829 | -containing the current locale formatting values. | ||
| 1830 | - | ||
| 1831 | -Here is how to query the database for the B<de> (Deutsch or German) locale. | ||
| 1832 | - | ||
| 1833 | - $loc = POSIX::setlocale( &POSIX::LC_ALL, "de" ); | ||
| 1834 | - print "Locale = $loc\n"; | ||
| 1835 | - $lconv = POSIX::localeconv(); | ||
| 1836 | - print "decimal_point = ", $lconv->{decimal_point}, "\n"; | ||
| 1837 | - print "thousands_sep = ", $lconv->{thousands_sep}, "\n"; | ||
| 1838 | - print "grouping = ", $lconv->{grouping}, "\n"; | ||
| 1839 | - print "int_curr_symbol = ", $lconv->{int_curr_symbol}, "\n"; | ||
| 1840 | - print "currency_symbol = ", $lconv->{currency_symbol}, "\n"; | ||
| 1841 | - print "mon_decimal_point = ", $lconv->{mon_decimal_point}, "\n"; | ||
| 1842 | - print "mon_thousands_sep = ", $lconv->{mon_thousands_sep}, "\n"; | ||
| 1843 | - print "mon_grouping = ", $lconv->{mon_grouping}, "\n"; | ||
| 1844 | - print "positive_sign = ", $lconv->{positive_sign}, "\n"; | ||
| 1845 | - print "negative_sign = ", $lconv->{negative_sign}, "\n"; | ||
| 1846 | - print "int_frac_digits = ", $lconv->{int_frac_digits}, "\n"; | ||
| 1847 | - print "frac_digits = ", $lconv->{frac_digits}, "\n"; | ||
| 1848 | - print "p_cs_precedes = ", $lconv->{p_cs_precedes}, "\n"; | ||
| 1849 | - print "p_sep_by_space = ", $lconv->{p_sep_by_space}, "\n"; | ||
| 1850 | - print "n_cs_precedes = ", $lconv->{n_cs_precedes}, "\n"; | ||
| 1851 | - print "n_sep_by_space = ", $lconv->{n_sep_by_space}, "\n"; | ||
| 1852 | - print "p_sign_posn = ", $lconv->{p_sign_posn}, "\n"; | ||
| 1853 | - print "n_sign_posn = ", $lconv->{n_sign_posn}, "\n"; | ||
| 1854 | - | ||
| 1855 | -=item localtime | ||
| 1856 | - | ||
| 1857 | -This is identical to Perl's builtin C<localtime()> function for | ||
| 1858 | -converting seconds since the epoch to a date see L<perlfunc/localtime>. | ||
| 1859 | - | ||
| 1860 | -=item log | ||
| 1861 | - | ||
| 1862 | -This is identical to Perl's builtin C<log()> function, | ||
| 1863 | -returning the natural (I<e>-based) logarithm of the numerical argument, | ||
| 1864 | -see L<perlfunc/log>. | ||
| 1865 | - | ||
| 1866 | -=item log10 | ||
| 1867 | - | ||
| 1868 | -This is identical to the C function C<log10()>, | ||
| 1869 | -returning the 10-base logarithm of the numerical argument. | ||
| 1870 | -You can also use | ||
| 1871 | - | ||
| 1872 | - sub log10 { log($_[0]) / log(10) } | ||
| 1873 | - | ||
| 1874 | -or | ||
| 1875 | - | ||
| 1876 | - sub log10 { log($_[0]) / 2.30258509299405 } | ||
| 1877 | - | ||
| 1878 | -or | ||
| 1879 | - | ||
| 1880 | - sub log10 { log($_[0]) * 0.434294481903252 } | ||
| 1881 | - | ||
| 1882 | -=item longjmp | ||
| 1883 | - | ||
| 1884 | -longjmp() is C-specific: use L<perlfunc/die> instead. | ||
| 1885 | - | ||
| 1886 | -=item lseek | ||
| 1887 | - | ||
| 1888 | -Move the file's read/write position. This uses file descriptors such as | ||
| 1889 | -those obtained by calling C<POSIX::open>. | ||
| 1890 | - | ||
| 1891 | - $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); | ||
| 1892 | - $off_t = POSIX::lseek( $fd, 0, &POSIX::SEEK_SET ); | ||
| 1893 | - | ||
| 1894 | -Returns C<undef> on failure. | ||
| 1895 | - | ||
| 1896 | -=item malloc | ||
| 1897 | - | ||
| 1898 | -malloc() is C-specific. Perl does memory management transparently. | ||
| 1899 | - | ||
| 1900 | -=item mblen | ||
| 1901 | - | ||
| 1902 | -This is identical to the C function C<mblen()>. | ||
| 1903 | -Perl does not have any support for the wide and multibyte | ||
| 1904 | -characters of the C standards, so this might be a rather | ||
| 1905 | -useless function. | ||
| 1906 | - | ||
| 1907 | -=item mbstowcs | ||
| 1908 | - | ||
| 1909 | -This is identical to the C function C<mbstowcs()>. | ||
| 1910 | -Perl does not have any support for the wide and multibyte | ||
| 1911 | -characters of the C standards, so this might be a rather | ||
| 1912 | -useless function. | ||
| 1913 | - | ||
| 1914 | -=item mbtowc | ||
| 1915 | - | ||
| 1916 | -This is identical to the C function C<mbtowc()>. | ||
| 1917 | -Perl does not have any support for the wide and multibyte | ||
| 1918 | -characters of the C standards, so this might be a rather | ||
| 1919 | -useless function. | ||
| 1920 | - | ||
| 1921 | -=item memchr | ||
| 1922 | - | ||
| 1923 | -memchr() is C-specific, see L<perlfunc/index> instead. | ||
| 1924 | - | ||
| 1925 | -=item memcmp | ||
| 1926 | - | ||
| 1927 | -memcmp() is C-specific, use C<eq> instead, see L<perlop>. | ||
| 1928 | - | ||
| 1929 | -=item memcpy | ||
| 1930 | - | ||
| 1931 | -memcpy() is C-specific, use C<=>, see L<perlop>, or see L<perlfunc/substr>. | ||
| 1932 | - | ||
| 1933 | -=item memmove | ||
| 1934 | - | ||
| 1935 | -memmove() is C-specific, use C<=>, see L<perlop>, or see L<perlfunc/substr>. | ||
| 1936 | - | ||
| 1937 | -=item memset | ||
| 1938 | - | ||
| 1939 | -memset() is C-specific, use C<x> instead, see L<perlop>. | ||
| 1940 | - | ||
| 1941 | -=item mkdir | ||
| 1942 | - | ||
| 1943 | -This is identical to Perl's builtin C<mkdir()> function | ||
| 1944 | -for creating directories, see L<perlfunc/mkdir>. | ||
| 1945 | - | ||
| 1946 | -=item mkfifo | ||
| 1947 | - | ||
| 1948 | -This is similar to the C function C<mkfifo()> for creating | ||
| 1949 | -FIFO special files. | ||
| 1950 | - | ||
| 1951 | - if (mkfifo($path, $mode)) { .... | ||
| 1952 | - | ||
| 1953 | -Returns C<undef> on failure. The C<$mode> is similar to the | ||
| 1954 | -mode of C<mkdir()>, see L<perlfunc/mkdir>, though for C<mkfifo> | ||
| 1955 | -you B<must> specify the C<$mode>. | ||
| 1956 | - | ||
| 1957 | -=item mktime | ||
| 1958 | - | ||
| 1959 | -Convert date/time info to a calendar time. | ||
| 1960 | - | ||
| 1961 | -Synopsis: | ||
| 1962 | - | ||
| 1963 | - mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = -1) | ||
| 1964 | - | ||
| 1965 | -The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero. | ||
| 1966 | -I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The | ||
| 1967 | -year (C<year>) is given in years since 1900. I.e. The year 1995 is 95; the | ||
| 1968 | -year 2001 is 101. Consult your system's C<mktime()> manpage for details | ||
| 1969 | -about these and the other arguments. | ||
| 1970 | - | ||
| 1971 | -Calendar time for December 12, 1995, at 10:30 am. | ||
| 1972 | - | ||
| 1973 | - $time_t = POSIX::mktime( 0, 30, 10, 12, 11, 95 ); | ||
| 1974 | - print "Date = ", POSIX::ctime($time_t); | ||
| 1975 | - | ||
| 1976 | -Returns C<undef> on failure. | ||
| 1977 | - | ||
| 1978 | -=item modf | ||
| 1979 | - | ||
| 1980 | -Return the integral and fractional parts of a floating-point number. | ||
| 1981 | - | ||
| 1982 | - ($fractional, $integral) = POSIX::modf( 3.14 ); | ||
| 1983 | - | ||
| 1984 | -=item nice | ||
| 1985 | - | ||
| 1986 | -This is similar to the C function C<nice()>, for changing | ||
| 1987 | -the scheduling preference of the current process. Positive | ||
| 1988 | -arguments mean more polite process, negative values more | ||
| 1989 | -needy process. Normal user processes can only be more polite. | ||
| 1990 | - | ||
| 1991 | -Returns C<undef> on failure. | ||
| 1992 | - | ||
| 1993 | -=item offsetof | ||
| 1994 | - | ||
| 1995 | -offsetof() is C-specific, you probably want to see L<perlfunc/pack> instead. | ||
| 1996 | - | ||
| 1997 | -=item open | ||
| 1998 | - | ||
| 1999 | -Open a file for reading for writing. This returns file descriptors, not | ||
| 2000 | -Perl filehandles. Use C<POSIX::close> to close the file. | ||
| 2001 | - | ||
| 2002 | -Open a file read-only with mode 0666. | ||
| 2003 | - | ||
| 2004 | - $fd = POSIX::open( "foo" ); | ||
| 2005 | - | ||
| 2006 | -Open a file for read and write. | ||
| 2007 | - | ||
| 2008 | - $fd = POSIX::open( "foo", &POSIX::O_RDWR ); | ||
| 2009 | - | ||
| 2010 | -Open a file for write, with truncation. | ||
| 2011 | - | ||
| 2012 | - $fd = POSIX::open( "foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC ); | ||
| 2013 | - | ||
| 2014 | -Create a new file with mode 0640. Set up the file for writing. | ||
| 2015 | - | ||
| 2016 | - $fd = POSIX::open( "foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0640 ); | ||
| 2017 | - | ||
| 2018 | -Returns C<undef> on failure. | ||
| 2019 | - | ||
| 2020 | -See also L<perlfunc/sysopen>. | ||
| 2021 | - | ||
| 2022 | -=item opendir | ||
| 2023 | - | ||
| 2024 | -Open a directory for reading. | ||
| 2025 | - | ||
| 2026 | - $dir = POSIX::opendir( "/var" ); | ||
| 2027 | - @files = POSIX::readdir( $dir ); | ||
| 2028 | - POSIX::closedir( $dir ); | ||
| 2029 | - | ||
| 2030 | -Returns C<undef> on failure. | ||
| 2031 | - | ||
| 2032 | -=item pathconf | ||
| 2033 | - | ||
| 2034 | -Retrieves the value of a configurable limit on a file or directory. | ||
| 2035 | - | ||
| 2036 | -The following will determine the maximum length of the longest allowable | ||
| 2037 | -pathname on the filesystem which holds C</var>. | ||
| 2038 | - | ||
| 2039 | - $path_max = POSIX::pathconf( "/var", &POSIX::_PC_PATH_MAX ); | ||
| 2040 | - | ||
| 2041 | -Returns C<undef> on failure. | ||
| 2042 | - | ||
| 2043 | -=item pause | ||
| 2044 | - | ||
| 2045 | -This is similar to the C function C<pause()>, which suspends | ||
| 2046 | -the execution of the current process until a signal is received. | ||
| 2047 | - | ||
| 2048 | -Returns C<undef> on failure. | ||
| 2049 | - | ||
| 2050 | -=item perror | ||
| 2051 | - | ||
| 2052 | -This is identical to the C function C<perror()>, which outputs to the | ||
| 2053 | -standard error stream the specified message followed by ": " and the | ||
| 2054 | -current error string. Use the C<warn()> function and the C<$!> | ||
| 2055 | -variable instead, see L<perlfunc/warn> and L<perlvar/$ERRNO>. | ||
| 2056 | - | ||
| 2057 | -=item pipe | ||
| 2058 | - | ||
| 2059 | -Create an interprocess channel. This returns file descriptors like those | ||
| 2060 | -returned by C<POSIX::open>. | ||
| 2061 | - | ||
| 2062 | - my ($read, $write) = POSIX::pipe(); | ||
| 2063 | - POSIX::write( $write, "hello", 5 ); | ||
| 2064 | - POSIX::read( $read, $buf, 5 ); | ||
| 2065 | - | ||
| 2066 | -See also L<perlfunc/pipe>. | ||
| 2067 | - | ||
| 2068 | -=item pow | ||
| 2069 | - | ||
| 2070 | -Computes C<$x> raised to the power C<$exponent>. | ||
| 2071 | - | ||
| 2072 | - $ret = POSIX::pow( $x, $exponent ); | ||
| 2073 | - | ||
| 2074 | -You can also use the C<**> operator, see L<perlop>. | ||
| 2075 | - | ||
| 2076 | -=item printf | ||
| 2077 | - | ||
| 2078 | -Formats and prints the specified arguments to STDOUT. | ||
| 2079 | -See also L<perlfunc/printf>. | ||
| 2080 | - | ||
| 2081 | -=item putc | ||
| 2082 | - | ||
| 2083 | -putc() is C-specific, see L<perlfunc/print> instead. | ||
| 2084 | - | ||
| 2085 | -=item putchar | ||
| 2086 | - | ||
| 2087 | -putchar() is C-specific, see L<perlfunc/print> instead. | ||
| 2088 | - | ||
| 2089 | -=item puts | ||
| 2090 | - | ||
| 2091 | -puts() is C-specific, see L<perlfunc/print> instead. | ||
| 2092 | - | ||
| 2093 | -=item qsort | ||
| 2094 | - | ||
| 2095 | -qsort() is C-specific, see L<perlfunc/sort> instead. | ||
| 2096 | - | ||
| 2097 | -=item raise | ||
| 2098 | - | ||
| 2099 | -Sends the specified signal to the current process. | ||
| 2100 | -See also L<perlfunc/kill> and the C<$$> in L<perlvar/$PID>. | ||
| 2101 | - | ||
| 2102 | -=item rand | ||
| 2103 | - | ||
| 2104 | -C<rand()> is non-portable, see L<perlfunc/rand> instead. | ||
| 2105 | - | ||
| 2106 | -=item read | ||
| 2107 | - | ||
| 2108 | -Read from a file. This uses file descriptors such as those obtained by | ||
| 2109 | -calling C<POSIX::open>. If the buffer C<$buf> is not large enough for the | ||
| 2110 | -read then Perl will extend it to make room for the request. | ||
| 2111 | - | ||
| 2112 | - $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); | ||
| 2113 | - $bytes = POSIX::read( $fd, $buf, 3 ); | ||
| 2114 | - | ||
| 2115 | -Returns C<undef> on failure. | ||
| 2116 | - | ||
| 2117 | -See also L<perlfunc/sysread>. | ||
| 2118 | - | ||
| 2119 | -=item readdir | ||
| 2120 | - | ||
| 2121 | -This is identical to Perl's builtin C<readdir()> function | ||
| 2122 | -for reading directory entries, see L<perlfunc/readdir>. | ||
| 2123 | - | ||
| 2124 | -=item realloc | ||
| 2125 | - | ||
| 2126 | -realloc() is C-specific. Perl does memory management transparently. | ||
| 2127 | - | ||
| 2128 | -=item remove | ||
| 2129 | - | ||
| 2130 | -This is identical to Perl's builtin C<unlink()> function | ||
| 2131 | -for removing files, see L<perlfunc/unlink>. | ||
| 2132 | - | ||
| 2133 | -=item rename | ||
| 2134 | - | ||
| 2135 | -This is identical to Perl's builtin C<rename()> function | ||
| 2136 | -for renaming files, see L<perlfunc/rename>. | ||
| 2137 | - | ||
| 2138 | -=item rewind | ||
| 2139 | - | ||
| 2140 | -Seeks to the beginning of the file. | ||
| 2141 | - | ||
| 2142 | -=item rewinddir | ||
| 2143 | - | ||
| 2144 | -This is identical to Perl's builtin C<rewinddir()> function for | ||
| 2145 | -rewinding directory entry streams, see L<perlfunc/rewinddir>. | ||
| 2146 | - | ||
| 2147 | -=item rmdir | ||
| 2148 | - | ||
| 2149 | -This is identical to Perl's builtin C<rmdir()> function | ||
| 2150 | -for removing (empty) directories, see L<perlfunc/rmdir>. | ||
| 2151 | - | ||
| 2152 | -=item scanf | ||
| 2153 | - | ||
| 2154 | -scanf() is C-specific, use E<lt>E<gt> and regular expressions instead, | ||
| 2155 | -see L<perlre>. | ||
| 2156 | - | ||
| 2157 | -=item setgid | ||
| 2158 | - | ||
| 2159 | -Sets the real group identifier and the effective group identifier for | ||
| 2160 | -this process. Similar to assigning a value to the Perl's builtin | ||
| 2161 | -C<$)> variable, see L<perlvar/$EGID>, except that the latter | ||
| 2162 | -will change only the real user identifier, and that the setgid() | ||
| 2163 | -uses only a single numeric argument, as opposed to a space-separated | ||
| 2164 | -list of numbers. | ||
| 2165 | - | ||
| 2166 | -=item setjmp | ||
| 2167 | - | ||
| 2168 | -C<setjmp()> is C-specific: use C<eval {}> instead, | ||
| 2169 | -see L<perlfunc/eval>. | ||
| 2170 | - | ||
| 2171 | -=item setlocale | ||
| 2172 | - | ||
| 2173 | -Modifies and queries program's locale. The following examples assume | ||
| 2174 | - | ||
| 2175 | - use POSIX qw(setlocale LC_ALL LC_CTYPE); | ||
| 2176 | - | ||
| 2177 | -has been issued. | ||
| 2178 | - | ||
| 2179 | -The following will set the traditional UNIX system locale behavior | ||
| 2180 | -(the second argument C<"C">). | ||
| 2181 | - | ||
| 2182 | - $loc = setlocale( LC_ALL, "C" ); | ||
| 2183 | - | ||
| 2184 | -The following will query the current LC_CTYPE category. (No second | ||
| 2185 | -argument means 'query'.) | ||
| 2186 | - | ||
| 2187 | - $loc = setlocale( LC_CTYPE ); | ||
| 2188 | - | ||
| 2189 | -The following will set the LC_CTYPE behaviour according to the locale | ||
| 2190 | -environment variables (the second argument C<"">). | ||
| 2191 | -Please see your systems C<setlocale(3)> documentation for the locale | ||
| 2192 | -environment variables' meaning or consult L<perllocale>. | ||
| 2193 | - | ||
| 2194 | - $loc = setlocale( LC_CTYPE, "" ); | ||
| 2195 | - | ||
| 2196 | -The following will set the LC_COLLATE behaviour to Argentinian | ||
| 2197 | -Spanish. B<NOTE>: The naming and availability of locales depends on | ||
| 2198 | -your operating system. Please consult L<perllocale> for how to find | ||
| 2199 | -out which locales are available in your system. | ||
| 2200 | - | ||
| 2201 | - $loc = setlocale( LC_COLLATE, "es_AR.ISO8859-1" ); | ||
| 2202 | - | ||
| 2203 | -=item setpgid | ||
| 2204 | - | ||
| 2205 | -This is similar to the C function C<setpgid()> for | ||
| 2206 | -setting the process group identifier of the current process. | ||
| 2207 | - | ||
| 2208 | -Returns C<undef> on failure. | ||
| 2209 | - | ||
| 2210 | -=item setsid | ||
| 2211 | - | ||
| 2212 | -This is identical to the C function C<setsid()> for | ||
| 2213 | -setting the session identifier of the current process. | ||
| 2214 | - | ||
| 2215 | -=item setuid | ||
| 2216 | - | ||
| 2217 | -Sets the real user identifier and the effective user identifier for | ||
| 2218 | -this process. Similar to assigning a value to the Perl's builtin | ||
| 2219 | -C<$E<lt>> variable, see L<perlvar/$UID>, except that the latter | ||
| 2220 | -will change only the real user identifier. | ||
| 2221 | - | ||
| 2222 | -=item sigaction | ||
| 2223 | - | ||
| 2224 | -Detailed signal management. This uses C<POSIX::SigAction> objects for | ||
| 2225 | -the C<action> and C<oldaction> arguments (the oldaction can also be | ||
| 2226 | -just a hash reference). Consult your system's C<sigaction> manpage | ||
| 2227 | -for details, see also C<POSIX::SigRt>. | ||
| 2228 | - | ||
| 2229 | -Synopsis: | ||
| 2230 | - | ||
| 2231 | - sigaction(signal, action, oldaction = 0) | ||
| 2232 | - | ||
| 2233 | -Returns C<undef> on failure. The C<signal> must be a number (like | ||
| 2234 | -SIGHUP), not a string (like "SIGHUP"), though Perl does try hard | ||
| 2235 | -to understand you. | ||
| 2236 | - | ||
| 2237 | -If you use the SA_SIGINFO flag, the signal handler will in addition to | ||
| 2238 | -the first argument, the signal name, also receive a second argument, a | ||
| 2239 | -hash reference, inside which are the following keys with the following | ||
| 2240 | -semantics, as defined by POSIX/SUSv3: | ||
| 2241 | - | ||
| 2242 | - signo the signal number | ||
| 2243 | - errno the error number | ||
| 2244 | - code if this is zero or less, the signal was sent by | ||
| 2245 | - a user process and the uid and pid make sense, | ||
| 2246 | - otherwise the signal was sent by the kernel | ||
| 2247 | - | ||
| 2248 | -The following are also defined by POSIX/SUSv3, but unfortunately | ||
| 2249 | -not very widely implemented: | ||
| 2250 | - | ||
| 2251 | - pid the process id generating the signal | ||
| 2252 | - uid the uid of the process id generating the signal | ||
| 2253 | - status exit value or signal for SIGCHLD | ||
| 2254 | - band band event for SIGPOLL | ||
| 2255 | - | ||
| 2256 | -A third argument is also passed to the handler, which contains a copy | ||
| 2257 | -of the raw binary contents of the siginfo structure: if a system has | ||
| 2258 | -some non-POSIX fields, this third argument is where to unpack() them | ||
| 2259 | -from. | ||
| 2260 | - | ||
| 2261 | -Note that not all siginfo values make sense simultaneously (some are | ||
| 2262 | -valid only for certain signals, for example), and not all values make | ||
| 2263 | -sense from Perl perspective, you should to consult your system's | ||
| 2264 | -C<sigaction> and possibly also C<siginfo> documentation. | ||
| 2265 | - | ||
| 2266 | -=item siglongjmp | ||
| 2267 | - | ||
| 2268 | -siglongjmp() is C-specific: use L<perlfunc/die> instead. | ||
| 2269 | - | ||
| 2270 | -=item sigpending | ||
| 2271 | - | ||
| 2272 | -Examine signals that are blocked and pending. This uses C<POSIX::SigSet> | ||
| 2273 | -objects for the C<sigset> argument. Consult your system's C<sigpending> | ||
| 2274 | -manpage for details. | ||
| 2275 | - | ||
| 2276 | -Synopsis: | ||
| 2277 | - | ||
| 2278 | - sigpending(sigset) | ||
| 2279 | - | ||
| 2280 | -Returns C<undef> on failure. | ||
| 2281 | - | ||
| 2282 | -=item sigprocmask | ||
| 2283 | - | ||
| 2284 | -Change and/or examine calling process's signal mask. This uses | ||
| 2285 | -C<POSIX::SigSet> objects for the C<sigset> and C<oldsigset> arguments. | ||
| 2286 | -Consult your system's C<sigprocmask> manpage for details. | ||
| 2287 | - | ||
| 2288 | -Synopsis: | ||
| 2289 | - | ||
| 2290 | - sigprocmask(how, sigset, oldsigset = 0) | ||
| 2291 | - | ||
| 2292 | -Returns C<undef> on failure. | ||
| 2293 | - | ||
| 2294 | -=item sigsetjmp | ||
| 2295 | - | ||
| 2296 | -C<sigsetjmp()> is C-specific: use C<eval {}> instead, | ||
| 2297 | -see L<perlfunc/eval>. | ||
| 2298 | - | ||
| 2299 | -=item sigsuspend | ||
| 2300 | - | ||
| 2301 | -Install a signal mask and suspend process until signal arrives. This uses | ||
| 2302 | -C<POSIX::SigSet> objects for the C<signal_mask> argument. Consult your | ||
| 2303 | -system's C<sigsuspend> manpage for details. | ||
| 2304 | - | ||
| 2305 | -Synopsis: | ||
| 2306 | - | ||
| 2307 | - sigsuspend(signal_mask) | ||
| 2308 | - | ||
| 2309 | -Returns C<undef> on failure. | ||
| 2310 | - | ||
| 2311 | -=item sin | ||
| 2312 | - | ||
| 2313 | -This is identical to Perl's builtin C<sin()> function | ||
| 2314 | -for returning the sine of the numerical argument, | ||
| 2315 | -see L<perlfunc/sin>. See also L<Math::Trig>. | ||
| 2316 | - | ||
| 2317 | -=item sinh | ||
| 2318 | - | ||
| 2319 | -This is identical to the C function C<sinh()> | ||
| 2320 | -for returning the hyperbolic sine of the numerical argument. | ||
| 2321 | -See also L<Math::Trig>. | ||
| 2322 | - | ||
| 2323 | -=item sleep | ||
| 2324 | - | ||
| 2325 | -This is functionally identical to Perl's builtin C<sleep()> function | ||
| 2326 | -for suspending the execution of the current for process for certain | ||
| 2327 | -number of seconds, see L<perlfunc/sleep>. There is one significant | ||
| 2328 | -difference, however: C<POSIX::sleep()> returns the number of | ||
| 2329 | -B<unslept> seconds, while the C<CORE::sleep()> returns the | ||
| 2330 | -number of slept seconds. | ||
| 2331 | - | ||
| 2332 | -=item sprintf | ||
| 2333 | - | ||
| 2334 | -This is similar to Perl's builtin C<sprintf()> function | ||
| 2335 | -for returning a string that has the arguments formatted as requested, | ||
| 2336 | -see L<perlfunc/sprintf>. | ||
| 2337 | - | ||
| 2338 | -=item sqrt | ||
| 2339 | - | ||
| 2340 | -This is identical to Perl's builtin C<sqrt()> function. | ||
| 2341 | -for returning the square root of the numerical argument, | ||
| 2342 | -see L<perlfunc/sqrt>. | ||
| 2343 | - | ||
| 2344 | -=item srand | ||
| 2345 | - | ||
| 2346 | -Give a seed the pseudorandom number generator, see L<perlfunc/srand>. | ||
| 2347 | - | ||
| 2348 | -=item sscanf | ||
| 2349 | - | ||
| 2350 | -sscanf() is C-specific, use regular expressions instead, | ||
| 2351 | -see L<perlre>. | ||
| 2352 | - | ||
| 2353 | -=item stat | ||
| 2354 | - | ||
| 2355 | -This is identical to Perl's builtin C<stat()> function | ||
| 2356 | -for returning information about files and directories. | ||
| 2357 | - | ||
| 2358 | -=item strcat | ||
| 2359 | - | ||
| 2360 | -strcat() is C-specific, use C<.=> instead, see L<perlop>. | ||
| 2361 | - | ||
| 2362 | -=item strchr | ||
| 2363 | - | ||
| 2364 | -strchr() is C-specific, see L<perlfunc/index> instead. | ||
| 2365 | - | ||
| 2366 | -=item strcmp | ||
| 2367 | - | ||
| 2368 | -strcmp() is C-specific, use C<eq> or C<cmp> instead, see L<perlop>. | ||
| 2369 | - | ||
| 2370 | -=item strcoll | ||
| 2371 | - | ||
| 2372 | -This is identical to the C function C<strcoll()> | ||
| 2373 | -for collating (comparing) strings transformed using | ||
| 2374 | -the C<strxfrm()> function. Not really needed since | ||
| 2375 | -Perl can do this transparently, see L<perllocale>. | ||
| 2376 | - | ||
| 2377 | -=item strcpy | ||
| 2378 | - | ||
| 2379 | -strcpy() is C-specific, use C<=> instead, see L<perlop>. | ||
| 2380 | - | ||
| 2381 | -=item strcspn | ||
| 2382 | - | ||
| 2383 | -strcspn() is C-specific, use regular expressions instead, | ||
| 2384 | -see L<perlre>. | ||
| 2385 | - | ||
| 2386 | -=item strerror | ||
| 2387 | - | ||
| 2388 | -Returns the error string for the specified errno. | ||
| 2389 | -Identical to the string form of the C<$!>, see L<perlvar/$ERRNO>. | ||
| 2390 | - | ||
| 2391 | -=item strftime | ||
| 2392 | - | ||
| 2393 | -Convert date and time information to string. Returns the string. | ||
| 2394 | - | ||
| 2395 | -Synopsis: | ||
| 2396 | - | ||
| 2397 | - strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) | ||
| 2398 | - | ||
| 2399 | -The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero. | ||
| 2400 | -I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The | ||
| 2401 | -year (C<year>) is given in years since 1900. I.e., the year 1995 is 95; the | ||
| 2402 | -year 2001 is 101. Consult your system's C<strftime()> manpage for details | ||
| 2403 | -about these and the other arguments. | ||
| 2404 | - | ||
| 2405 | -If you want your code to be portable, your format (C<fmt>) argument | ||
| 2406 | -should use only the conversion specifiers defined by the ANSI C | ||
| 2407 | -standard (C89, to play safe). These are C<aAbBcdHIjmMpSUwWxXyYZ%>. | ||
| 2408 | -But even then, the B<results> of some of the conversion specifiers are | ||
| 2409 | -non-portable. For example, the specifiers C<aAbBcpZ> change according | ||
| 2410 | -to the locale settings of the user, and both how to set locales (the | ||
| 2411 | -locale names) and what output to expect are non-standard. | ||
| 2412 | -The specifier C<c> changes according to the timezone settings of the | ||
| 2413 | -user and the timezone computation rules of the operating system. | ||
| 2414 | -The C<Z> specifier is notoriously unportable since the names of | ||
| 2415 | -timezones are non-standard. Sticking to the numeric specifiers is the | ||
| 2416 | -safest route. | ||
| 2417 | - | ||
| 2418 | -The given arguments are made consistent as though by calling | ||
| 2419 | -C<mktime()> before calling your system's C<strftime()> function, | ||
| 2420 | -except that the C<isdst> value is not affected. | ||
| 2421 | - | ||
| 2422 | -The string for Tuesday, December 12, 1995. | ||
| 2423 | - | ||
| 2424 | - $str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 ); | ||
| 2425 | - print "$str\n"; | ||
| 2426 | - | ||
| 2427 | -=item strlen | ||
| 2428 | - | ||
| 2429 | -strlen() is C-specific, use C<length()> instead, see L<perlfunc/length>. | ||
| 2430 | - | ||
| 2431 | -=item strncat | ||
| 2432 | - | ||
| 2433 | -strncat() is C-specific, use C<.=> instead, see L<perlop>. | ||
| 2434 | - | ||
| 2435 | -=item strncmp | ||
| 2436 | - | ||
| 2437 | -strncmp() is C-specific, use C<eq> instead, see L<perlop>. | ||
| 2438 | - | ||
| 2439 | -=item strncpy | ||
| 2440 | - | ||
| 2441 | -strncpy() is C-specific, use C<=> instead, see L<perlop>. | ||
| 2442 | - | ||
| 2443 | -=item strpbrk | ||
| 2444 | - | ||
| 2445 | -strpbrk() is C-specific, use regular expressions instead, | ||
| 2446 | -see L<perlre>. | ||
| 2447 | - | ||
| 2448 | -=item strrchr | ||
| 2449 | - | ||
| 2450 | -strrchr() is C-specific, see L<perlfunc/rindex> instead. | ||
| 2451 | - | ||
| 2452 | -=item strspn | ||
| 2453 | - | ||
| 2454 | -strspn() is C-specific, use regular expressions instead, | ||
| 2455 | -see L<perlre>. | ||
| 2456 | - | ||
| 2457 | -=item strstr | ||
| 2458 | - | ||
| 2459 | -This is identical to Perl's builtin C<index()> function, | ||
| 2460 | -see L<perlfunc/index>. | ||
| 2461 | - | ||
| 2462 | -=item strtod | ||
| 2463 | - | ||
| 2464 | -String to double translation. Returns the parsed number and the number | ||
| 2465 | -of characters in the unparsed portion of the string. Truly | ||
| 2466 | -POSIX-compliant systems set $! ($ERRNO) to indicate a translation | ||
| 2467 | -error, so clear $! before calling strtod. However, non-POSIX systems | ||
| 2468 | -may not check for overflow, and therefore will never set $!. | ||
| 2469 | - | ||
| 2470 | -strtod should respect any POSIX I<setlocale()> settings. | ||
| 2471 | - | ||
| 2472 | -To parse a string $str as a floating point number use | ||
| 2473 | - | ||
| 2474 | - $! = 0; | ||
| 2475 | - ($num, $n_unparsed) = POSIX::strtod($str); | ||
| 2476 | - | ||
| 2477 | -The second returned item and $! can be used to check for valid input: | ||
| 2478 | - | ||
| 2479 | - if (($str eq '') || ($n_unparsed != 0) || $!) { | ||
| 2480 | - die "Non-numeric input $str" . ($! ? ": $!\n" : "\n"); | ||
| 2481 | - } | ||
| 2482 | - | ||
| 2483 | -When called in a scalar context strtod returns the parsed number. | ||
| 2484 | - | ||
| 2485 | -=item strtok | ||
| 2486 | - | ||
| 2487 | -strtok() is C-specific, use regular expressions instead, see | ||
| 2488 | -L<perlre>, or L<perlfunc/split>. | ||
| 2489 | - | ||
| 2490 | -=item strtol | ||
| 2491 | - | ||
| 2492 | -String to (long) integer translation. Returns the parsed number and | ||
| 2493 | -the number of characters in the unparsed portion of the string. Truly | ||
| 2494 | -POSIX-compliant systems set $! ($ERRNO) to indicate a translation | ||
| 2495 | -error, so clear $! before calling strtol. However, non-POSIX systems | ||
| 2496 | -may not check for overflow, and therefore will never set $!. | ||
| 2497 | - | ||
| 2498 | -strtol should respect any POSIX I<setlocale()> settings. | ||
| 2499 | - | ||
| 2500 | -To parse a string $str as a number in some base $base use | ||
| 2501 | - | ||
| 2502 | - $! = 0; | ||
| 2503 | - ($num, $n_unparsed) = POSIX::strtol($str, $base); | ||
| 2504 | - | ||
| 2505 | -The base should be zero or between 2 and 36, inclusive. When the base | ||
| 2506 | -is zero or omitted strtol will use the string itself to determine the | ||
| 2507 | -base: a leading "0x" or "0X" means hexadecimal; a leading "0" means | ||
| 2508 | -octal; any other leading characters mean decimal. Thus, "1234" is | ||
| 2509 | -parsed as a decimal number, "01234" as an octal number, and "0x1234" | ||
| 2510 | -as a hexadecimal number. | ||
| 2511 | - | ||
| 2512 | -The second returned item and $! can be used to check for valid input: | ||
| 2513 | - | ||
| 2514 | - if (($str eq '') || ($n_unparsed != 0) || !$!) { | ||
| 2515 | - die "Non-numeric input $str" . $! ? ": $!\n" : "\n"; | ||
| 2516 | - } | ||
| 2517 | - | ||
| 2518 | -When called in a scalar context strtol returns the parsed number. | ||
| 2519 | - | ||
| 2520 | -=item strtoul | ||
| 2521 | - | ||
| 2522 | -String to unsigned (long) integer translation. strtoul() is identical | ||
| 2523 | -to strtol() except that strtoul() only parses unsigned integers. See | ||
| 2524 | -L</strtol> for details. | ||
| 2525 | - | ||
| 2526 | -Note: Some vendors supply strtod() and strtol() but not strtoul(). | ||
| 2527 | -Other vendors that do supply strtoul() parse "-1" as a valid value. | ||
| 2528 | - | ||
| 2529 | -=item strxfrm | ||
| 2530 | - | ||
| 2531 | -String transformation. Returns the transformed string. | ||
| 2532 | - | ||
| 2533 | - $dst = POSIX::strxfrm( $src ); | ||
| 2534 | - | ||
| 2535 | -Used in conjunction with the C<strcoll()> function, see L</strcoll>. | ||
| 2536 | - | ||
| 2537 | -Not really needed since Perl can do this transparently, see | ||
| 2538 | -L<perllocale>. | ||
| 2539 | - | ||
| 2540 | -=item sysconf | ||
| 2541 | - | ||
| 2542 | -Retrieves values of system configurable variables. | ||
| 2543 | - | ||
| 2544 | -The following will get the machine's clock speed. | ||
| 2545 | - | ||
| 2546 | - $clock_ticks = POSIX::sysconf( &POSIX::_SC_CLK_TCK ); | ||
| 2547 | - | ||
| 2548 | -Returns C<undef> on failure. | ||
| 2549 | - | ||
| 2550 | -=item system | ||
| 2551 | - | ||
| 2552 | -This is identical to Perl's builtin C<system()> function, see | ||
| 2553 | -L<perlfunc/system>. | ||
| 2554 | - | ||
| 2555 | -=item tan | ||
| 2556 | - | ||
| 2557 | -This is identical to the C function C<tan()>, returning the | ||
| 2558 | -tangent of the numerical argument. See also L<Math::Trig>. | ||
| 2559 | - | ||
| 2560 | -=item tanh | ||
| 2561 | - | ||
| 2562 | -This is identical to the C function C<tanh()>, returning the | ||
| 2563 | -hyperbolic tangent of the numerical argument. See also L<Math::Trig>. | ||
| 2564 | - | ||
| 2565 | -=item tcdrain | ||
| 2566 | - | ||
| 2567 | -This is similar to the C function C<tcdrain()> for draining | ||
| 2568 | -the output queue of its argument stream. | ||
| 2569 | - | ||
| 2570 | -Returns C<undef> on failure. | ||
| 2571 | - | ||
| 2572 | -=item tcflow | ||
| 2573 | - | ||
| 2574 | -This is similar to the C function C<tcflow()> for controlling | ||
| 2575 | -the flow of its argument stream. | ||
| 2576 | - | ||
| 2577 | -Returns C<undef> on failure. | ||
| 2578 | - | ||
| 2579 | -=item tcflush | ||
| 2580 | - | ||
| 2581 | -This is similar to the C function C<tcflush()> for flushing | ||
| 2582 | -the I/O buffers of its argument stream. | ||
| 2583 | - | ||
| 2584 | -Returns C<undef> on failure. | ||
| 2585 | - | ||
| 2586 | -=item tcgetpgrp | ||
| 2587 | - | ||
| 2588 | -This is identical to the C function C<tcgetpgrp()> for returning the | ||
| 2589 | -process group identifier of the foreground process group of the controlling | ||
| 2590 | -terminal. | ||
| 2591 | - | ||
| 2592 | -=item tcsendbreak | ||
| 2593 | - | ||
| 2594 | -This is similar to the C function C<tcsendbreak()> for sending | ||
| 2595 | -a break on its argument stream. | ||
| 2596 | - | ||
| 2597 | -Returns C<undef> on failure. | ||
| 2598 | - | ||
| 2599 | -=item tcsetpgrp | ||
| 2600 | - | ||
| 2601 | -This is similar to the C function C<tcsetpgrp()> for setting the | ||
| 2602 | -process group identifier of the foreground process group of the controlling | ||
| 2603 | -terminal. | ||
| 2604 | - | ||
| 2605 | -Returns C<undef> on failure. | ||
| 2606 | - | ||
| 2607 | -=item time | ||
| 2608 | - | ||
| 2609 | -This is identical to Perl's builtin C<time()> function | ||
| 2610 | -for returning the number of seconds since the epoch | ||
| 2611 | -(whatever it is for the system), see L<perlfunc/time>. | ||
| 2612 | - | ||
| 2613 | -=item times | ||
| 2614 | - | ||
| 2615 | -The times() function returns elapsed realtime since some point in the past | ||
| 2616 | -(such as system startup), user and system times for this process, and user | ||
| 2617 | -and system times used by child processes. All times are returned in clock | ||
| 2618 | -ticks. | ||
| 2619 | - | ||
| 2620 | - ($realtime, $user, $system, $cuser, $csystem) = POSIX::times(); | ||
| 2621 | - | ||
| 2622 | -Note: Perl's builtin C<times()> function returns four values, measured in | ||
| 2623 | -seconds. | ||
| 2624 | - | ||
| 2625 | -=item tmpfile | ||
| 2626 | - | ||
| 2627 | -Use method C<IO::File::new_tmpfile()> instead, or see L<File::Temp>. | ||
| 2628 | - | ||
| 2629 | -=item tmpnam | ||
| 2630 | - | ||
| 2631 | -Returns a name for a temporary file. | ||
| 2632 | - | ||
| 2633 | - $tmpfile = POSIX::tmpnam(); | ||
| 2634 | - | ||
| 2635 | -For security reasons, which are probably detailed in your system's | ||
| 2636 | -documentation for the C library tmpnam() function, this interface | ||
| 2637 | -should not be used; instead see L<File::Temp>. | ||
| 2638 | - | ||
| 2639 | -=item tolower | ||
| 2640 | - | ||
| 2641 | -This is identical to the C function, except that it can apply to a single | ||
| 2642 | -character or to a whole string. Consider using the C<lc()> function, | ||
| 2643 | -see L<perlfunc/lc>, or the equivalent C<\L> operator inside doublequotish | ||
| 2644 | -strings. | ||
| 2645 | - | ||
| 2646 | -=item toupper | ||
| 2647 | - | ||
| 2648 | -This is identical to the C function, except that it can apply to a single | ||
| 2649 | -character or to a whole string. Consider using the C<uc()> function, | ||
| 2650 | -see L<perlfunc/uc>, or the equivalent C<\U> operator inside doublequotish | ||
| 2651 | -strings. | ||
| 2652 | - | ||
| 2653 | -=item ttyname | ||
| 2654 | - | ||
| 2655 | -This is identical to the C function C<ttyname()> for returning the | ||
| 2656 | -name of the current terminal. | ||
| 2657 | - | ||
| 2658 | -=item tzname | ||
| 2659 | - | ||
| 2660 | -Retrieves the time conversion information from the C<tzname> variable. | ||
| 2661 | - | ||
| 2662 | - POSIX::tzset(); | ||
| 2663 | - ($std, $dst) = POSIX::tzname(); | ||
| 2664 | - | ||
| 2665 | -=item tzset | ||
| 2666 | - | ||
| 2667 | -This is identical to the C function C<tzset()> for setting | ||
| 2668 | -the current timezone based on the environment variable C<TZ>, | ||
| 2669 | -to be used by C<ctime()>, C<localtime()>, C<mktime()>, and C<strftime()> | ||
| 2670 | -functions. | ||
| 2671 | - | ||
| 2672 | -=item umask | ||
| 2673 | - | ||
| 2674 | -This is identical to Perl's builtin C<umask()> function | ||
| 2675 | -for setting (and querying) the file creation permission mask, | ||
| 2676 | -see L<perlfunc/umask>. | ||
| 2677 | - | ||
| 2678 | -=item uname | ||
| 2679 | - | ||
| 2680 | -Get name of current operating system. | ||
| 2681 | - | ||
| 2682 | - ($sysname, $nodename, $release, $version, $machine) = POSIX::uname(); | ||
| 2683 | - | ||
| 2684 | -Note that the actual meanings of the various fields are not | ||
| 2685 | -that well standardized, do not expect any great portability. | ||
| 2686 | -The C<$sysname> might be the name of the operating system, | ||
| 2687 | -the C<$nodename> might be the name of the host, the C<$release> | ||
| 2688 | -might be the (major) release number of the operating system, | ||
| 2689 | -the C<$version> might be the (minor) release number of the | ||
| 2690 | -operating system, and the C<$machine> might be a hardware identifier. | ||
| 2691 | -Maybe. | ||
| 2692 | - | ||
| 2693 | -=item ungetc | ||
| 2694 | - | ||
| 2695 | -Use method C<IO::Handle::ungetc()> instead. | ||
| 2696 | - | ||
| 2697 | -=item unlink | ||
| 2698 | - | ||
| 2699 | -This is identical to Perl's builtin C<unlink()> function | ||
| 2700 | -for removing files, see L<perlfunc/unlink>. | ||
| 2701 | - | ||
| 2702 | -=item utime | ||
| 2703 | - | ||
| 2704 | -This is identical to Perl's builtin C<utime()> function | ||
| 2705 | -for changing the time stamps of files and directories, | ||
| 2706 | -see L<perlfunc/utime>. | ||
| 2707 | - | ||
| 2708 | -=item vfprintf | ||
| 2709 | - | ||
| 2710 | -vfprintf() is C-specific, see L<perlfunc/printf> instead. | ||
| 2711 | - | ||
| 2712 | -=item vprintf | ||
| 2713 | - | ||
| 2714 | -vprintf() is C-specific, see L<perlfunc/printf> instead. | ||
| 2715 | - | ||
| 2716 | -=item vsprintf | ||
| 2717 | - | ||
| 2718 | -vsprintf() is C-specific, see L<perlfunc/sprintf> instead. | ||
| 2719 | - | ||
| 2720 | -=item wait | ||
| 2721 | - | ||
| 2722 | -This is identical to Perl's builtin C<wait()> function, | ||
| 2723 | -see L<perlfunc/wait>. | ||
| 2724 | - | ||
| 2725 | -=item waitpid | ||
| 2726 | - | ||
| 2727 | -Wait for a child process to change state. This is identical to Perl's | ||
| 2728 | -builtin C<waitpid()> function, see L<perlfunc/waitpid>. | ||
| 2729 | - | ||
| 2730 | - $pid = POSIX::waitpid( -1, POSIX::WNOHANG ); | ||
| 2731 | - print "status = ", ($? / 256), "\n"; | ||
| 2732 | - | ||
| 2733 | -=item wcstombs | ||
| 2734 | - | ||
| 2735 | -This is identical to the C function C<wcstombs()>. | ||
| 2736 | -Perl does not have any support for the wide and multibyte | ||
| 2737 | -characters of the C standards, so this might be a rather | ||
| 2738 | -useless function. | ||
| 2739 | - | ||
| 2740 | -=item wctomb | ||
| 2741 | - | ||
| 2742 | -This is identical to the C function C<wctomb()>. | ||
| 2743 | -Perl does not have any support for the wide and multibyte | ||
| 2744 | -characters of the C standards, so this might be a rather | ||
| 2745 | -useless function. | ||
| 2746 | - | ||
| 2747 | -=item write | ||
| 2748 | - | ||
| 2749 | -Write to a file. This uses file descriptors such as those obtained by | ||
| 2750 | -calling C<POSIX::open>. | ||
| 2751 | - | ||
| 2752 | - $fd = POSIX::open( "foo", &POSIX::O_WRONLY ); | ||
| 2753 | - $buf = "hello"; | ||
| 2754 | - $bytes = POSIX::write( $fd, $buf, 5 ); | ||
| 2755 | - | ||
| 2756 | -Returns C<undef> on failure. | ||
| 2757 | - | ||
| 2758 | -See also L<perlfunc/syswrite>. | ||
| 2759 | - | ||
| 2760 | -=back | ||
| 2761 | - | ||
| 2762 | -=head1 CLASSES | ||
| 2763 | - | ||
| 2764 | -=head2 POSIX::SigAction | ||
| 2765 | - | ||
| 2766 | -=over 8 | ||
| 2767 | - | ||
| 2768 | -=item new | ||
| 2769 | - | ||
| 2770 | -Creates a new C<POSIX::SigAction> object which corresponds to the C | ||
| 2771 | -C<struct sigaction>. This object will be destroyed automatically when | ||
| 2772 | -it is no longer needed. The first parameter is the handler, a sub | ||
| 2773 | -reference. The second parameter is a C<POSIX::SigSet> object, it | ||
| 2774 | -defaults to the empty set. The third parameter contains the | ||
| 2775 | -C<sa_flags>, it defaults to 0. | ||
| 2776 | - | ||
| 2777 | - $sigset = POSIX::SigSet->new(SIGINT, SIGQUIT); | ||
| 2778 | - $sigaction = POSIX::SigAction->new( \&handler, $sigset, &POSIX::SA_NOCLDSTOP ); | ||
| 2779 | - | ||
| 2780 | -This C<POSIX::SigAction> object is intended for use with the C<POSIX::sigaction()> | ||
| 2781 | -function. | ||
| 2782 | - | ||
| 2783 | -=back | ||
| 2784 | - | ||
| 2785 | -=over 8 | ||
| 2786 | - | ||
| 2787 | -=item handler | ||
| 2788 | - | ||
| 2789 | -=item mask | ||
| 2790 | - | ||
| 2791 | -=item flags | ||
| 2792 | - | ||
| 2793 | -accessor functions to get/set the values of a SigAction object. | ||
| 2794 | - | ||
| 2795 | - $sigset = $sigaction->mask; | ||
| 2796 | - $sigaction->flags(&POSIX::SA_RESTART); | ||
| 2797 | - | ||
| 2798 | -=item safe | ||
| 2799 | - | ||
| 2800 | -accessor function for the "safe signals" flag of a SigAction object; see | ||
| 2801 | -L<perlipc> for general information on safe (a.k.a. "deferred") signals. If | ||
| 2802 | -you wish to handle a signal safely, use this accessor to set the "safe" flag | ||
| 2803 | -in the C<POSIX::SigAction> object: | ||
| 2804 | - | ||
| 2805 | - $sigaction->safe(1); | ||
| 2806 | - | ||
| 2807 | -You may also examine the "safe" flag on the output action object which is | ||
| 2808 | -filled in when given as the third parameter to C<POSIX::sigaction()>: | ||
| 2809 | - | ||
| 2810 | - sigaction(SIGINT, $new_action, $old_action); | ||
| 2811 | - if ($old_action->safe) { | ||
| 2812 | - # previous SIGINT handler used safe signals | ||
| 2813 | - } | ||
| 2814 | - | ||
| 2815 | -=back | ||
| 2816 | - | ||
| 2817 | -=head2 POSIX::SigRt | ||
| 2818 | - | ||
| 2819 | -=over 8 | ||
| 2820 | - | ||
| 2821 | -=item %SIGRT | ||
| 2822 | - | ||
| 2823 | -A hash of the POSIX realtime signal handlers. It is an extension of | ||
| 2824 | -the standard %SIG, the $POSIX::SIGRT{SIGRTMIN} is roughly equivalent | ||
| 2825 | -to $SIG{SIGRTMIN}, but the right POSIX moves (see below) are made with | ||
| 2826 | -the POSIX::SigSet and POSIX::sigaction instead of accessing the %SIG. | ||
| 2827 | - | ||
| 2828 | -You can set the %POSIX::SIGRT elements to set the POSIX realtime | ||
| 2829 | -signal handlers, use C<delete> and C<exists> on the elements, and use | ||
| 2830 | -C<scalar> on the C<%POSIX::SIGRT> to find out how many POSIX realtime | ||
| 2831 | -signals there are available (SIGRTMAX - SIGRTMIN + 1, the SIGRTMAX is | ||
| 2832 | -a valid POSIX realtime signal). | ||
| 2833 | - | ||
| 2834 | -Setting the %SIGRT elements is equivalent to calling this: | ||
| 2835 | - | ||
| 2836 | - sub new { | ||
| 2837 | - my ($rtsig, $handler, $flags) = @_; | ||
| 2838 | - my $sigset = POSIX::SigSet($rtsig); | ||
| 2839 | - my $sigact = POSIX::SigAction->new($handler, $sigset, $flags); | ||
| 2840 | - sigaction($rtsig, $sigact); | ||
| 2841 | - } | ||
| 2842 | - | ||
| 2843 | -The flags default to zero, if you want something different you can | ||
| 2844 | -either use C<local> on $POSIX::SigRt::SIGACTION_FLAGS, or you can | ||
| 2845 | -derive from POSIX::SigRt and define your own C<new()> (the tied hash | ||
| 2846 | -STORE method of the %SIGRT calls C<new($rtsig, $handler, $SIGACTION_FLAGS)>, | ||
| 2847 | -where the $rtsig ranges from zero to SIGRTMAX - SIGRTMIN + 1). | ||
| 2848 | - | ||
| 2849 | -Just as with any signal, you can use sigaction($rtsig, undef, $oa) to | ||
| 2850 | -retrieve the installed signal handler (or, rather, the signal action). | ||
| 2851 | - | ||
| 2852 | -B<NOTE:> whether POSIX realtime signals really work in your system, or | ||
| 2853 | -whether Perl has been compiled so that it works with them, is outside | ||
| 2854 | -of this discussion. | ||
| 2855 | - | ||
| 2856 | -=item SIGRTMIN | ||
| 2857 | - | ||
| 2858 | -Return the minimum POSIX realtime signal number available, or C<undef> | ||
| 2859 | -if no POSIX realtime signals are available. | ||
| 2860 | - | ||
| 2861 | -=item SIGRTMAX | ||
| 2862 | - | ||
| 2863 | -Return the maximum POSIX realtime signal number available, or C<undef> | ||
| 2864 | -if no POSIX realtime signals are available. | ||
| 2865 | - | ||
| 2866 | -=back | ||
| 2867 | - | ||
| 2868 | -=head2 POSIX::SigSet | ||
| 2869 | - | ||
| 2870 | -=over 8 | ||
| 2871 | - | ||
| 2872 | -=item new | ||
| 2873 | - | ||
| 2874 | -Create a new SigSet object. This object will be destroyed automatically | ||
| 2875 | -when it is no longer needed. Arguments may be supplied to initialize the | ||
| 2876 | -set. | ||
| 2877 | - | ||
| 2878 | -Create an empty set. | ||
| 2879 | - | ||
| 2880 | - $sigset = POSIX::SigSet->new; | ||
| 2881 | - | ||
| 2882 | -Create a set with SIGUSR1. | ||
| 2883 | - | ||
| 2884 | - $sigset = POSIX::SigSet->new( &POSIX::SIGUSR1 ); | ||
| 2885 | - | ||
| 2886 | -=item addset | ||
| 2887 | - | ||
| 2888 | -Add a signal to a SigSet object. | ||
| 2889 | - | ||
| 2890 | - $sigset->addset( &POSIX::SIGUSR2 ); | ||
| 2891 | - | ||
| 2892 | -Returns C<undef> on failure. | ||
| 2893 | - | ||
| 2894 | -=item delset | ||
| 2895 | - | ||
| 2896 | -Remove a signal from the SigSet object. | ||
| 2897 | - | ||
| 2898 | - $sigset->delset( &POSIX::SIGUSR2 ); | ||
| 2899 | - | ||
| 2900 | -Returns C<undef> on failure. | ||
| 2901 | - | ||
| 2902 | -=item emptyset | ||
| 2903 | - | ||
| 2904 | -Initialize the SigSet object to be empty. | ||
| 2905 | - | ||
| 2906 | - $sigset->emptyset(); | ||
| 2907 | - | ||
| 2908 | -Returns C<undef> on failure. | ||
| 2909 | - | ||
| 2910 | -=item fillset | ||
| 2911 | - | ||
| 2912 | -Initialize the SigSet object to include all signals. | ||
| 2913 | - | ||
| 2914 | - $sigset->fillset(); | ||
| 2915 | - | ||
| 2916 | -Returns C<undef> on failure. | ||
| 2917 | - | ||
| 2918 | -=item ismember | ||
| 2919 | - | ||
| 2920 | -Tests the SigSet object to see if it contains a specific signal. | ||
| 2921 | - | ||
| 2922 | - if( $sigset->ismember( &POSIX::SIGUSR1 ) ){ | ||
| 2923 | - print "contains SIGUSR1\n"; | ||
| 2924 | - } | ||
| 2925 | - | ||
| 2926 | -=back | ||
| 2927 | - | ||
| 2928 | -=head2 POSIX::Termios | ||
| 2929 | - | ||
| 2930 | -=over 8 | ||
| 2931 | - | ||
| 2932 | -=item new | ||
| 2933 | - | ||
| 2934 | -Create a new Termios object. This object will be destroyed automatically | ||
| 2935 | -when it is no longer needed. A Termios object corresponds to the termios | ||
| 2936 | -C struct. new() mallocs a new one, getattr() fills it from a file descriptor, | ||
| 2937 | -and setattr() sets a file descriptor's parameters to match Termios' contents. | ||
| 2938 | - | ||
| 2939 | - $termios = POSIX::Termios->new; | ||
| 2940 | - | ||
| 2941 | -=item getattr | ||
| 2942 | - | ||
| 2943 | -Get terminal control attributes. | ||
| 2944 | - | ||
| 2945 | -Obtain the attributes for stdin. | ||
| 2946 | - | ||
| 2947 | - $termios->getattr( 0 ) # Recommended for clarity. | ||
| 2948 | - $termios->getattr() | ||
| 2949 | - | ||
| 2950 | -Obtain the attributes for stdout. | ||
| 2951 | - | ||
| 2952 | - $termios->getattr( 1 ) | ||
| 2953 | - | ||
| 2954 | -Returns C<undef> on failure. | ||
| 2955 | - | ||
| 2956 | -=item getcc | ||
| 2957 | - | ||
| 2958 | -Retrieve a value from the c_cc field of a termios object. The c_cc field is | ||
| 2959 | -an array so an index must be specified. | ||
| 2960 | - | ||
| 2961 | - $c_cc[1] = $termios->getcc(1); | ||
| 2962 | - | ||
| 2963 | -=item getcflag | ||
| 2964 | - | ||
| 2965 | -Retrieve the c_cflag field of a termios object. | ||
| 2966 | - | ||
| 2967 | - $c_cflag = $termios->getcflag; | ||
| 2968 | - | ||
| 2969 | -=item getiflag | ||
| 2970 | - | ||
| 2971 | -Retrieve the c_iflag field of a termios object. | ||
| 2972 | - | ||
| 2973 | - $c_iflag = $termios->getiflag; | ||
| 2974 | - | ||
| 2975 | -=item getispeed | ||
| 2976 | - | ||
| 2977 | -Retrieve the input baud rate. | ||
| 2978 | - | ||
| 2979 | - $ispeed = $termios->getispeed; | ||
| 2980 | - | ||
| 2981 | -=item getlflag | ||
| 2982 | - | ||
| 2983 | -Retrieve the c_lflag field of a termios object. | ||
| 2984 | - | ||
| 2985 | - $c_lflag = $termios->getlflag; | ||
| 2986 | - | ||
| 2987 | -=item getoflag | ||
| 2988 | - | ||
| 2989 | -Retrieve the c_oflag field of a termios object. | ||
| 2990 | - | ||
| 2991 | - $c_oflag = $termios->getoflag; | ||
| 2992 | - | ||
| 2993 | -=item getospeed | ||
| 2994 | - | ||
| 2995 | -Retrieve the output baud rate. | ||
| 2996 | - | ||
| 2997 | - $ospeed = $termios->getospeed; | ||
| 2998 | - | ||
| 2999 | -=item setattr | ||
| 3000 | - | ||
| 3001 | -Set terminal control attributes. | ||
| 3002 | - | ||
| 3003 | -Set attributes immediately for stdout. | ||
| 3004 | - | ||
| 3005 | - $termios->setattr( 1, &POSIX::TCSANOW ); | ||
| 3006 | - | ||
| 3007 | -Returns C<undef> on failure. | ||
| 3008 | - | ||
| 3009 | -=item setcc | ||
| 3010 | - | ||
| 3011 | -Set a value in the c_cc field of a termios object. The c_cc field is an | ||
| 3012 | -array so an index must be specified. | ||
| 3013 | - | ||
| 3014 | - $termios->setcc( &POSIX::VEOF, 1 ); | ||
| 3015 | - | ||
| 3016 | -=item setcflag | ||
| 3017 | - | ||
| 3018 | -Set the c_cflag field of a termios object. | ||
| 3019 | - | ||
| 3020 | - $termios->setcflag( $c_cflag | &POSIX::CLOCAL ); | ||
| 3021 | - | ||
| 3022 | -=item setiflag | ||
| 3023 | - | ||
| 3024 | -Set the c_iflag field of a termios object. | ||
| 3025 | - | ||
| 3026 | - $termios->setiflag( $c_iflag | &POSIX::BRKINT ); | ||
| 3027 | - | ||
| 3028 | -=item setispeed | ||
| 3029 | - | ||
| 3030 | -Set the input baud rate. | ||
| 3031 | - | ||
| 3032 | - $termios->setispeed( &POSIX::B9600 ); | ||
| 3033 | - | ||
| 3034 | -Returns C<undef> on failure. | ||
| 3035 | - | ||
| 3036 | -=item setlflag | ||
| 3037 | - | ||
| 3038 | -Set the c_lflag field of a termios object. | ||
| 3039 | - | ||
| 3040 | - $termios->setlflag( $c_lflag | &POSIX::ECHO ); | ||
| 3041 | - | ||
| 3042 | -=item setoflag | ||
| 3043 | - | ||
| 3044 | -Set the c_oflag field of a termios object. | ||
| 3045 | - | ||
| 3046 | - $termios->setoflag( $c_oflag | &POSIX::OPOST ); | ||
| 3047 | - | ||
| 3048 | -=item setospeed | ||
| 3049 | - | ||
| 3050 | -Set the output baud rate. | ||
| 3051 | - | ||
| 3052 | - $termios->setospeed( &POSIX::B9600 ); | ||
| 3053 | - | ||
| 3054 | -Returns C<undef> on failure. | ||
| 3055 | - | ||
| 3056 | -=item Baud rate values | ||
| 3057 | - | ||
| 3058 | -B38400 B75 B200 B134 B300 B1800 B150 B0 B19200 B1200 B9600 B600 B4800 B50 B2400 B110 | ||
| 3059 | - | ||
| 3060 | -=item Terminal interface values | ||
| 3061 | - | ||
| 3062 | -TCSADRAIN TCSANOW TCOON TCIOFLUSH TCOFLUSH TCION TCIFLUSH TCSAFLUSH TCIOFF TCOOFF | ||
| 3063 | - | ||
| 3064 | -=item c_cc field values | ||
| 3065 | - | ||
| 3066 | -VEOF VEOL VERASE VINTR VKILL VQUIT VSUSP VSTART VSTOP VMIN VTIME NCCS | ||
| 3067 | - | ||
| 3068 | -=item c_cflag field values | ||
| 3069 | - | ||
| 3070 | -CLOCAL CREAD CSIZE CS5 CS6 CS7 CS8 CSTOPB HUPCL PARENB PARODD | ||
| 3071 | - | ||
| 3072 | -=item c_iflag field values | ||
| 3073 | - | ||
| 3074 | -BRKINT ICRNL IGNBRK IGNCR IGNPAR INLCR INPCK ISTRIP IXOFF IXON PARMRK | ||
| 3075 | - | ||
| 3076 | -=item c_lflag field values | ||
| 3077 | - | ||
| 3078 | -ECHO ECHOE ECHOK ECHONL ICANON IEXTEN ISIG NOFLSH TOSTOP | ||
| 3079 | - | ||
| 3080 | -=item c_oflag field values | ||
| 3081 | - | ||
| 3082 | -OPOST | ||
| 3083 | - | ||
| 3084 | -=back | ||
| 3085 | - | ||
| 3086 | -=head1 PATHNAME CONSTANTS | ||
| 3087 | - | ||
| 3088 | -=over 8 | ||
| 3089 | - | ||
| 3090 | -=item Constants | ||
| 3091 | - | ||
| 3092 | -_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 | ||
| 3093 | - | ||
| 3094 | -=back | ||
| 3095 | - | ||
| 3096 | -=head1 POSIX CONSTANTS | ||
| 3097 | - | ||
| 3098 | -=over 8 | ||
| 3099 | - | ||
| 3100 | -=item Constants | ||
| 3101 | - | ||
| 3102 | -_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 | ||
| 3103 | - | ||
| 3104 | -=back | ||
| 3105 | - | ||
| 3106 | -=head1 SYSTEM CONFIGURATION | ||
| 3107 | - | ||
| 3108 | -=over 8 | ||
| 3109 | - | ||
| 3110 | -=item Constants | ||
| 3111 | - | ||
| 3112 | -_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 | ||
| 3113 | - | ||
| 3114 | -=back | ||
| 3115 | - | ||
| 3116 | -=head1 ERRNO | ||
| 3117 | - | ||
| 3118 | -=over 8 | ||
| 3119 | - | ||
| 3120 | -=item Constants | ||
| 3121 | - | ||
| 3122 | -E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT EAGAIN EALREADY EBADF | ||
| 3123 | -EBUSY ECHILD ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ | ||
| 3124 | -EDOM EDQUOT EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH EINPROGRESS EINTR | ||
| 3125 | -EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE ENAMETOOLONG | ||
| 3126 | -ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODEV ENOENT ENOEXEC | ||
| 3127 | -ENOLCK ENOMEM ENOPROTOOPT ENOSPC ENOSYS ENOTBLK ENOTCONN ENOTDIR | ||
| 3128 | -ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM EPFNOSUPPORT EPIPE | ||
| 3129 | -EPROCLIM EPROTONOSUPPORT EPROTOTYPE ERANGE EREMOTE ERESTART EROFS | ||
| 3130 | -ESHUTDOWN ESOCKTNOSUPPORT ESPIPE ESRCH ESTALE ETIMEDOUT ETOOMANYREFS | ||
| 3131 | -ETXTBSY EUSERS EWOULDBLOCK EXDEV | ||
| 3132 | - | ||
| 3133 | -=back | ||
| 3134 | - | ||
| 3135 | -=head1 FCNTL | ||
| 3136 | - | ||
| 3137 | -=over 8 | ||
| 3138 | - | ||
| 3139 | -=item Constants | ||
| 3140 | - | ||
| 3141 | -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 | ||
| 3142 | - | ||
| 3143 | -=back | ||
| 3144 | - | ||
| 3145 | -=head1 FLOAT | ||
| 3146 | - | ||
| 3147 | -=over 8 | ||
| 3148 | - | ||
| 3149 | -=item Constants | ||
| 3150 | - | ||
| 3151 | -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 | ||
| 3152 | - | ||
| 3153 | -=back | ||
| 3154 | - | ||
| 3155 | -=head1 LIMITS | ||
| 3156 | - | ||
| 3157 | -=over 8 | ||
| 3158 | - | ||
| 3159 | -=item Constants | ||
| 3160 | - | ||
| 3161 | -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 | ||
| 3162 | - | ||
| 3163 | -=back | ||
| 3164 | - | ||
| 3165 | -=head1 LOCALE | ||
| 3166 | - | ||
| 3167 | -=over 8 | ||
| 3168 | - | ||
| 3169 | -=item Constants | ||
| 3170 | - | ||
| 3171 | -LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME | ||
| 3172 | - | ||
| 3173 | -=back | ||
| 3174 | - | ||
| 3175 | -=head1 MATH | ||
| 3176 | - | ||
| 3177 | -=over 8 | ||
| 3178 | - | ||
| 3179 | -=item Constants | ||
| 3180 | - | ||
| 3181 | -HUGE_VAL | ||
| 3182 | - | ||
| 3183 | -=back | ||
| 3184 | - | ||
| 3185 | -=head1 SIGNAL | ||
| 3186 | - | ||
| 3187 | -=over 8 | ||
| 3188 | - | ||
| 3189 | -=item Constants | ||
| 3190 | - | ||
| 3191 | -SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK SA_RESETHAND SA_RESTART | ||
| 3192 | -SA_SIGINFO SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT | ||
| 3193 | -SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU | ||
| 3194 | -SIGUSR1 SIGUSR2 SIG_BLOCK SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK | ||
| 3195 | -SIG_UNBLOCK | ||
| 3196 | - | ||
| 3197 | -=back | ||
| 3198 | - | ||
| 3199 | -=head1 STAT | ||
| 3200 | - | ||
| 3201 | -=over 8 | ||
| 3202 | - | ||
| 3203 | -=item Constants | ||
| 3204 | - | ||
| 3205 | -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 | ||
| 3206 | - | ||
| 3207 | -=item Macros | ||
| 3208 | - | ||
| 3209 | -S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG | ||
| 3210 | - | ||
| 3211 | -=back | ||
| 3212 | - | ||
| 3213 | -=head1 STDLIB | ||
| 3214 | - | ||
| 3215 | -=over 8 | ||
| 3216 | - | ||
| 3217 | -=item Constants | ||
| 3218 | - | ||
| 3219 | -EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX RAND_MAX | ||
| 3220 | - | ||
| 3221 | -=back | ||
| 3222 | - | ||
| 3223 | -=head1 STDIO | ||
| 3224 | - | ||
| 3225 | -=over 8 | ||
| 3226 | - | ||
| 3227 | -=item Constants | ||
| 3228 | - | ||
| 3229 | -BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid L_tmpname TMP_MAX | ||
| 3230 | - | ||
| 3231 | -=back | ||
| 3232 | - | ||
| 3233 | -=head1 TIME | ||
| 3234 | - | ||
| 3235 | -=over 8 | ||
| 3236 | - | ||
| 3237 | -=item Constants | ||
| 3238 | - | ||
| 3239 | -CLK_TCK CLOCKS_PER_SEC | ||
| 3240 | - | ||
| 3241 | -=back | ||
| 3242 | - | ||
| 3243 | -=head1 UNISTD | ||
| 3244 | - | ||
| 3245 | -=over 8 | ||
| 3246 | - | ||
| 3247 | -=item Constants | ||
| 3248 | - | ||
| 3249 | -R_OK SEEK_CUR SEEK_END SEEK_SET STDIN_FILENO STDOUT_FILENO STDERR_FILENO W_OK X_OK | ||
| 3250 | - | ||
| 3251 | -=back | ||
| 3252 | - | ||
| 3253 | -=head1 WAIT | ||
| 3254 | - | ||
| 3255 | -=over 8 | ||
| 3256 | - | ||
| 3257 | -=item Constants | ||
| 3258 | - | ||
| 3259 | -WNOHANG WUNTRACED | ||
| 3260 | - | ||
| 3261 | -=over 16 | ||
| 3262 | - | ||
| 3263 | -=item WNOHANG | ||
| 3264 | - | ||
| 3265 | -Do not suspend the calling process until a child process | ||
| 3266 | -changes state but instead return immediately. | ||
| 3267 | - | ||
| 3268 | -=item WUNTRACED | ||
| 3269 | - | ||
| 3270 | -Catch stopped child processes. | ||
| 3271 | - | ||
| 3272 | -=back | ||
| 3273 | - | ||
| 3274 | -=item Macros | ||
| 3275 | - | ||
| 3276 | -WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG | ||
| 3277 | - | ||
| 3278 | -=over 16 | ||
| 3279 | - | ||
| 3280 | -=item WIFEXITED | ||
| 3281 | - | ||
| 3282 | -WIFEXITED($?) returns true if the child process exited normally | ||
| 3283 | -(C<exit()> or by falling off the end of C<main()>) | ||
| 3284 | - | ||
| 3285 | -=item WEXITSTATUS | ||
| 3286 | - | ||
| 3287 | -WEXITSTATUS($?) returns the normal exit status of the child process | ||
| 3288 | -(only meaningful if WIFEXITED($?) is true) | ||
| 3289 | - | ||
| 3290 | -=item WIFSIGNALED | ||
| 3291 | - | ||
| 3292 | -WIFSIGNALED($?) returns true if the child process terminated because | ||
| 3293 | -of a signal | ||
| 3294 | - | ||
| 3295 | -=item WTERMSIG | ||
| 3296 | - | ||
| 3297 | -WTERMSIG($?) returns the signal the child process terminated for | ||
| 3298 | -(only meaningful if WIFSIGNALED($?) is true) | ||
| 3299 | - | ||
| 3300 | -=item WIFSTOPPED | ||
| 3301 | - | ||
| 3302 | -WIFSTOPPED($?) returns true if the child process is currently stopped | ||
| 3303 | -(can happen only if you specified the WUNTRACED flag to waitpid()) | ||
| 3304 | - | ||
| 3305 | -=item WSTOPSIG | ||
| 3306 | - | ||
| 3307 | -WSTOPSIG($?) returns the signal the child process was stopped for | ||
| 3308 | -(only meaningful if WIFSTOPPED($?) is true) | ||
| 3309 | - | ||
| 3310 | -=back | ||
| 3311 | - | ||
| 3312 | -=back | ||
| 3313 | - | ||
| 3314 | diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm | ||
| 3315 | new file mode 100644 | ||
| 3316 | index 0000000..ffbd9de | ||
| 3317 | --- /dev/null | ||
| 3318 | +++ b/ext/POSIX/lib/POSIX.pm | ||
| 3319 | @@ -0,0 +1,1042 @@ | ||
| 3320 | +package POSIX; | ||
| 3321 | +use strict; | ||
| 3322 | +use warnings; | ||
| 3323 | + | ||
| 3324 | +our(@ISA, %EXPORT_TAGS, @EXPORT_OK, @EXPORT, $AUTOLOAD, %SIGRT) = (); | ||
| 3325 | + | ||
| 3326 | +our $VERSION = "1.19"; | ||
| 3327 | + | ||
| 3328 | +use AutoLoader; | ||
| 3329 | + | ||
| 3330 | +use XSLoader (); | ||
| 3331 | + | ||
| 3332 | +use Fcntl qw(FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK F_SETFD | ||
| 3333 | + F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK O_ACCMODE O_APPEND | ||
| 3334 | + O_CREAT O_EXCL O_NOCTTY O_NONBLOCK O_RDONLY O_RDWR O_TRUNC | ||
| 3335 | + O_WRONLY SEEK_CUR SEEK_END SEEK_SET | ||
| 3336 | + S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG | ||
| 3337 | + S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU S_ISGID S_ISUID | ||
| 3338 | + S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR); | ||
| 3339 | + | ||
| 3340 | +# Grandfather old foo_h form to new :foo_h form | ||
| 3341 | +my $loaded; | ||
| 3342 | + | ||
| 3343 | +sub import { | ||
| 3344 | + load_imports() unless $loaded++; | ||
| 3345 | + my $this = shift; | ||
| 3346 | + my @list = map { m/^\w+_h$/ ? ":$_" : $_ } @_; | ||
| 3347 | + local $Exporter::ExportLevel = 1; | ||
| 3348 | + Exporter::import($this,@list); | ||
| 3349 | +} | ||
| 3350 | + | ||
| 3351 | +sub croak { require Carp; goto &Carp::croak } | ||
| 3352 | +# declare usage to assist AutoLoad | ||
| 3353 | +sub usage; | ||
| 3354 | + | ||
| 3355 | +XSLoader::load 'POSIX', $VERSION; | ||
| 3356 | + | ||
| 3357 | +sub AUTOLOAD { | ||
| 3358 | + no strict; | ||
| 3359 | + no warnings 'uninitialized'; | ||
| 3360 | + if ($AUTOLOAD =~ /::(_?[a-z])/) { | ||
| 3361 | + # require AutoLoader; | ||
| 3362 | + $AutoLoader::AUTOLOAD = $AUTOLOAD; | ||
| 3363 | + goto &AutoLoader::AUTOLOAD | ||
| 3364 | + } | ||
| 3365 | + local $! = 0; | ||
| 3366 | + my $constname = $AUTOLOAD; | ||
| 3367 | + $constname =~ s/.*:://; | ||
| 3368 | + my ($error, $val) = constant($constname); | ||
| 3369 | + croak $error if $error; | ||
| 3370 | + *$AUTOLOAD = sub { $val }; | ||
| 3371 | + | ||
| 3372 | + goto &$AUTOLOAD; | ||
| 3373 | +} | ||
| 3374 | + | ||
| 3375 | +package POSIX::SigAction; | ||
| 3376 | + | ||
| 3377 | +use AutoLoader 'AUTOLOAD'; | ||
| 3378 | + | ||
| 3379 | +package POSIX::SigRt; | ||
| 3380 | + | ||
| 3381 | +use AutoLoader 'AUTOLOAD'; | ||
| 3382 | + | ||
| 3383 | +use Tie::Hash; | ||
| 3384 | + | ||
| 3385 | +use vars qw($SIGACTION_FLAGS $_SIGRTMIN $_SIGRTMAX $_sigrtn @ISA); | ||
| 3386 | +@POSIX::SigRt::ISA = qw(Tie::StdHash); | ||
| 3387 | + | ||
| 3388 | +$SIGACTION_FLAGS = 0; | ||
| 3389 | + | ||
| 3390 | +tie %POSIX::SIGRT, 'POSIX::SigRt'; | ||
| 3391 | + | ||
| 3392 | +sub DESTROY {}; | ||
| 3393 | + | ||
| 3394 | +package POSIX; | ||
| 3395 | + | ||
| 3396 | +1; | ||
| 3397 | +__END__ | ||
| 3398 | + | ||
| 3399 | +sub usage { | ||
| 3400 | + my ($mess) = @_; | ||
| 3401 | + croak "Usage: POSIX::$mess"; | ||
| 3402 | +} | ||
| 3403 | + | ||
| 3404 | +sub redef { | ||
| 3405 | + my ($mess) = @_; | ||
| 3406 | + croak "Use method $mess instead"; | ||
| 3407 | +} | ||
| 3408 | + | ||
| 3409 | +sub unimpl { | ||
| 3410 | + my ($mess) = @_; | ||
| 3411 | + $mess =~ s/xxx//; | ||
| 3412 | + croak "Unimplemented: POSIX::$mess"; | ||
| 3413 | +} | ||
| 3414 | + | ||
| 3415 | +sub assert { | ||
| 3416 | + usage "assert(expr)" if @_ != 1; | ||
| 3417 | + if (!$_[0]) { | ||
| 3418 | + croak "Assertion failed"; | ||
| 3419 | + } | ||
| 3420 | +} | ||
| 3421 | + | ||
| 3422 | +sub tolower { | ||
| 3423 | + usage "tolower(string)" if @_ != 1; | ||
| 3424 | + lc($_[0]); | ||
| 3425 | +} | ||
| 3426 | + | ||
| 3427 | +sub toupper { | ||
| 3428 | + usage "toupper(string)" if @_ != 1; | ||
| 3429 | + uc($_[0]); | ||
| 3430 | +} | ||
| 3431 | + | ||
| 3432 | +sub closedir { | ||
| 3433 | + usage "closedir(dirhandle)" if @_ != 1; | ||
| 3434 | + CORE::closedir($_[0]); | ||
| 3435 | +} | ||
| 3436 | + | ||
| 3437 | +sub opendir { | ||
| 3438 | + usage "opendir(directory)" if @_ != 1; | ||
| 3439 | + my $dirhandle; | ||
| 3440 | + CORE::opendir($dirhandle, $_[0]) | ||
| 3441 | + ? $dirhandle | ||
| 3442 | + : undef; | ||
| 3443 | +} | ||
| 3444 | + | ||
| 3445 | +sub readdir { | ||
| 3446 | + usage "readdir(dirhandle)" if @_ != 1; | ||
| 3447 | + CORE::readdir($_[0]); | ||
| 3448 | +} | ||
| 3449 | + | ||
| 3450 | +sub rewinddir { | ||
| 3451 | + usage "rewinddir(dirhandle)" if @_ != 1; | ||
| 3452 | + CORE::rewinddir($_[0]); | ||
| 3453 | +} | ||
| 3454 | + | ||
| 3455 | +sub errno { | ||
| 3456 | + usage "errno()" if @_ != 0; | ||
| 3457 | + $! + 0; | ||
| 3458 | +} | ||
| 3459 | + | ||
| 3460 | +sub creat { | ||
| 3461 | + usage "creat(filename, mode)" if @_ != 2; | ||
| 3462 | + &open($_[0], &O_WRONLY | &O_CREAT | &O_TRUNC, $_[1]); | ||
| 3463 | +} | ||
| 3464 | + | ||
| 3465 | +sub fcntl { | ||
| 3466 | + usage "fcntl(filehandle, cmd, arg)" if @_ != 3; | ||
| 3467 | + CORE::fcntl($_[0], $_[1], $_[2]); | ||
| 3468 | +} | ||
| 3469 | + | ||
| 3470 | +sub getgrgid { | ||
| 3471 | + usage "getgrgid(gid)" if @_ != 1; | ||
| 3472 | + CORE::getgrgid($_[0]); | ||
| 3473 | +} | ||
| 3474 | + | ||
| 3475 | +sub getgrnam { | ||
| 3476 | + usage "getgrnam(name)" if @_ != 1; | ||
| 3477 | + CORE::getgrnam($_[0]); | ||
| 3478 | +} | ||
| 3479 | + | ||
| 3480 | +sub atan2 { | ||
| 3481 | + usage "atan2(x,y)" if @_ != 2; | ||
| 3482 | + CORE::atan2($_[0], $_[1]); | ||
| 3483 | +} | ||
| 3484 | + | ||
| 3485 | +sub cos { | ||
| 3486 | + usage "cos(x)" if @_ != 1; | ||
| 3487 | + CORE::cos($_[0]); | ||
| 3488 | +} | ||
| 3489 | + | ||
| 3490 | +sub exp { | ||
| 3491 | + usage "exp(x)" if @_ != 1; | ||
| 3492 | + CORE::exp($_[0]); | ||
| 3493 | +} | ||
| 3494 | + | ||
| 3495 | +sub fabs { | ||
| 3496 | + usage "fabs(x)" if @_ != 1; | ||
| 3497 | + CORE::abs($_[0]); | ||
| 3498 | +} | ||
| 3499 | + | ||
| 3500 | +sub log { | ||
| 3501 | + usage "log(x)" if @_ != 1; | ||
| 3502 | + CORE::log($_[0]); | ||
| 3503 | +} | ||
| 3504 | + | ||
| 3505 | +sub pow { | ||
| 3506 | + usage "pow(x,exponent)" if @_ != 2; | ||
| 3507 | + $_[0] ** $_[1]; | ||
| 3508 | +} | ||
| 3509 | + | ||
| 3510 | +sub sin { | ||
| 3511 | + usage "sin(x)" if @_ != 1; | ||
| 3512 | + CORE::sin($_[0]); | ||
| 3513 | +} | ||
| 3514 | + | ||
| 3515 | +sub sqrt { | ||
| 3516 | + usage "sqrt(x)" if @_ != 1; | ||
| 3517 | + CORE::sqrt($_[0]); | ||
| 3518 | +} | ||
| 3519 | + | ||
| 3520 | +sub getpwnam { | ||
| 3521 | + usage "getpwnam(name)" if @_ != 1; | ||
| 3522 | + CORE::getpwnam($_[0]); | ||
| 3523 | +} | ||
| 3524 | + | ||
| 3525 | +sub getpwuid { | ||
| 3526 | + usage "getpwuid(uid)" if @_ != 1; | ||
| 3527 | + CORE::getpwuid($_[0]); | ||
| 3528 | +} | ||
| 3529 | + | ||
| 3530 | +sub longjmp { | ||
| 3531 | + unimpl "longjmp() is C-specific: use die instead"; | ||
| 3532 | +} | ||
| 3533 | + | ||
| 3534 | +sub setjmp { | ||
| 3535 | + unimpl "setjmp() is C-specific: use eval {} instead"; | ||
| 3536 | +} | ||
| 3537 | + | ||
| 3538 | +sub siglongjmp { | ||
| 3539 | + unimpl "siglongjmp() is C-specific: use die instead"; | ||
| 3540 | +} | ||
| 3541 | + | ||
| 3542 | +sub sigsetjmp { | ||
| 3543 | + unimpl "sigsetjmp() is C-specific: use eval {} instead"; | ||
| 3544 | +} | ||
| 3545 | + | ||
| 3546 | +sub kill { | ||
| 3547 | + usage "kill(pid, sig)" if @_ != 2; | ||
| 3548 | + CORE::kill $_[1], $_[0]; | ||
| 3549 | +} | ||
| 3550 | + | ||
| 3551 | +sub raise { | ||
| 3552 | + usage "raise(sig)" if @_ != 1; | ||
| 3553 | + CORE::kill $_[0], $$; # Is this good enough? | ||
| 3554 | +} | ||
| 3555 | + | ||
| 3556 | +sub offsetof { | ||
| 3557 | + unimpl "offsetof() is C-specific, stopped"; | ||
| 3558 | +} | ||
| 3559 | + | ||
| 3560 | +sub clearerr { | ||
| 3561 | + redef "IO::Handle::clearerr()"; | ||
| 3562 | +} | ||
| 3563 | + | ||
| 3564 | +sub fclose { | ||
| 3565 | + redef "IO::Handle::close()"; | ||
| 3566 | +} | ||
| 3567 | + | ||
| 3568 | +sub fdopen { | ||
| 3569 | + redef "IO::Handle::new_from_fd()"; | ||
| 3570 | +} | ||
| 3571 | + | ||
| 3572 | +sub feof { | ||
| 3573 | + redef "IO::Handle::eof()"; | ||
| 3574 | +} | ||
| 3575 | + | ||
| 3576 | +sub fgetc { | ||
| 3577 | + redef "IO::Handle::getc()"; | ||
| 3578 | +} | ||
| 3579 | + | ||
| 3580 | +sub fgets { | ||
| 3581 | + redef "IO::Handle::gets()"; | ||
| 3582 | +} | ||
| 3583 | + | ||
| 3584 | +sub fileno { | ||
| 3585 | + redef "IO::Handle::fileno()"; | ||
| 3586 | +} | ||
| 3587 | + | ||
| 3588 | +sub fopen { | ||
| 3589 | + redef "IO::File::open()"; | ||
| 3590 | +} | ||
| 3591 | + | ||
| 3592 | +sub fprintf { | ||
| 3593 | + unimpl "fprintf() is C-specific--use printf instead"; | ||
| 3594 | +} | ||
| 3595 | + | ||
| 3596 | +sub fputc { | ||
| 3597 | + unimpl "fputc() is C-specific--use print instead"; | ||
| 3598 | +} | ||
| 3599 | + | ||
| 3600 | +sub fputs { | ||
| 3601 | + unimpl "fputs() is C-specific--use print instead"; | ||
| 3602 | +} | ||
| 3603 | + | ||
| 3604 | +sub fread { | ||
| 3605 | + unimpl "fread() is C-specific--use read instead"; | ||
| 3606 | +} | ||
| 3607 | + | ||
| 3608 | +sub freopen { | ||
| 3609 | + unimpl "freopen() is C-specific--use open instead"; | ||
| 3610 | +} | ||
| 3611 | + | ||
| 3612 | +sub fscanf { | ||
| 3613 | + unimpl "fscanf() is C-specific--use <> and regular expressions instead"; | ||
| 3614 | +} | ||
| 3615 | + | ||
| 3616 | +sub fseek { | ||
| 3617 | + redef "IO::Seekable::seek()"; | ||
| 3618 | +} | ||
| 3619 | + | ||
| 3620 | +sub fsync { | ||
| 3621 | + redef "IO::Handle::sync()"; | ||
| 3622 | +} | ||
| 3623 | + | ||
| 3624 | +sub ferror { | ||
| 3625 | + redef "IO::Handle::error()"; | ||
| 3626 | +} | ||
| 3627 | + | ||
| 3628 | +sub fflush { | ||
| 3629 | + redef "IO::Handle::flush()"; | ||
| 3630 | +} | ||
| 3631 | + | ||
| 3632 | +sub fgetpos { | ||
| 3633 | + redef "IO::Seekable::getpos()"; | ||
| 3634 | +} | ||
| 3635 | + | ||
| 3636 | +sub fsetpos { | ||
| 3637 | + redef "IO::Seekable::setpos()"; | ||
| 3638 | +} | ||
| 3639 | + | ||
| 3640 | +sub ftell { | ||
| 3641 | + redef "IO::Seekable::tell()"; | ||
| 3642 | +} | ||
| 3643 | + | ||
| 3644 | +sub fwrite { | ||
| 3645 | + unimpl "fwrite() is C-specific--use print instead"; | ||
| 3646 | +} | ||
| 3647 | + | ||
| 3648 | +sub getc { | ||
| 3649 | + usage "getc(handle)" if @_ != 1; | ||
| 3650 | + CORE::getc($_[0]); | ||
| 3651 | +} | ||
| 3652 | + | ||
| 3653 | +sub getchar { | ||
| 3654 | + usage "getchar()" if @_ != 0; | ||
| 3655 | + CORE::getc(STDIN); | ||
| 3656 | +} | ||
| 3657 | + | ||
| 3658 | +sub gets { | ||
| 3659 | + usage "gets()" if @_ != 0; | ||
| 3660 | + scalar <STDIN>; | ||
| 3661 | +} | ||
| 3662 | + | ||
| 3663 | +sub perror { | ||
| 3664 | + print STDERR "@_: " if @_; | ||
| 3665 | + print STDERR $!,"\n"; | ||
| 3666 | +} | ||
| 3667 | + | ||
| 3668 | +sub printf { | ||
| 3669 | + usage "printf(pattern, args...)" if @_ < 1; | ||
| 3670 | + CORE::printf STDOUT @_; | ||
| 3671 | +} | ||
| 3672 | + | ||
| 3673 | +sub putc { | ||
| 3674 | + unimpl "putc() is C-specific--use print instead"; | ||
| 3675 | +} | ||
| 3676 | + | ||
| 3677 | +sub putchar { | ||
| 3678 | + unimpl "putchar() is C-specific--use print instead"; | ||
| 3679 | +} | ||
| 3680 | + | ||
| 3681 | +sub puts { | ||
| 3682 | + unimpl "puts() is C-specific--use print instead"; | ||
| 3683 | +} | ||
| 3684 | + | ||
| 3685 | +sub remove { | ||
| 3686 | + usage "remove(filename)" if @_ != 1; | ||
| 3687 | + (-d $_[0]) ? CORE::rmdir($_[0]) : CORE::unlink($_[0]); | ||
| 3688 | +} | ||
| 3689 | + | ||
| 3690 | +sub rename { | ||
| 3691 | + usage "rename(oldfilename, newfilename)" if @_ != 2; | ||
| 3692 | + CORE::rename($_[0], $_[1]); | ||
| 3693 | +} | ||
| 3694 | + | ||
| 3695 | +sub rewind { | ||
| 3696 | + usage "rewind(filehandle)" if @_ != 1; | ||
| 3697 | + CORE::seek($_[0],0,0); | ||
| 3698 | +} | ||
| 3699 | + | ||
| 3700 | +sub scanf { | ||
| 3701 | + unimpl "scanf() is C-specific--use <> and regular expressions instead"; | ||
| 3702 | +} | ||
| 3703 | + | ||
| 3704 | +sub sprintf { | ||
| 3705 | + usage "sprintf(pattern,args)" if @_ == 0; | ||
| 3706 | + CORE::sprintf(shift,@_); | ||
| 3707 | +} | ||
| 3708 | + | ||
| 3709 | +sub sscanf { | ||
| 3710 | + unimpl "sscanf() is C-specific--use regular expressions instead"; | ||
| 3711 | +} | ||
| 3712 | + | ||
| 3713 | +sub tmpfile { | ||
| 3714 | + redef "IO::File::new_tmpfile()"; | ||
| 3715 | +} | ||
| 3716 | + | ||
| 3717 | +sub ungetc { | ||
| 3718 | + redef "IO::Handle::ungetc()"; | ||
| 3719 | +} | ||
| 3720 | + | ||
| 3721 | +sub vfprintf { | ||
| 3722 | + unimpl "vfprintf() is C-specific"; | ||
| 3723 | +} | ||
| 3724 | + | ||
| 3725 | +sub vprintf { | ||
| 3726 | + unimpl "vprintf() is C-specific"; | ||
| 3727 | +} | ||
| 3728 | + | ||
| 3729 | +sub vsprintf { | ||
| 3730 | + unimpl "vsprintf() is C-specific"; | ||
| 3731 | +} | ||
| 3732 | + | ||
| 3733 | +sub abs { | ||
| 3734 | + usage "abs(x)" if @_ != 1; | ||
| 3735 | + CORE::abs($_[0]); | ||
| 3736 | +} | ||
| 3737 | + | ||
| 3738 | +sub atexit { | ||
| 3739 | + unimpl "atexit() is C-specific: use END {} instead"; | ||
| 3740 | +} | ||
| 3741 | + | ||
| 3742 | +sub atof { | ||
| 3743 | + unimpl "atof() is C-specific, stopped"; | ||
| 3744 | +} | ||
| 3745 | + | ||
| 3746 | +sub atoi { | ||
| 3747 | + unimpl "atoi() is C-specific, stopped"; | ||
| 3748 | +} | ||
| 3749 | + | ||
| 3750 | +sub atol { | ||
| 3751 | + unimpl "atol() is C-specific, stopped"; | ||
| 3752 | +} | ||
| 3753 | + | ||
| 3754 | +sub bsearch { | ||
| 3755 | + unimpl "bsearch() not supplied"; | ||
| 3756 | +} | ||
| 3757 | + | ||
| 3758 | +sub calloc { | ||
| 3759 | + unimpl "calloc() is C-specific, stopped"; | ||
| 3760 | +} | ||
| 3761 | + | ||
| 3762 | +sub div { | ||
| 3763 | + unimpl "div() is C-specific, use /, % and int instead"; | ||
| 3764 | +} | ||
| 3765 | + | ||
| 3766 | +sub exit { | ||
| 3767 | + usage "exit(status)" if @_ != 1; | ||
| 3768 | + CORE::exit($_[0]); | ||
| 3769 | +} | ||
| 3770 | + | ||
| 3771 | +sub free { | ||
| 3772 | + unimpl "free() is C-specific, stopped"; | ||
| 3773 | +} | ||
| 3774 | + | ||
| 3775 | +sub getenv { | ||
| 3776 | + usage "getenv(name)" if @_ != 1; | ||
| 3777 | + $ENV{$_[0]}; | ||
| 3778 | +} | ||
| 3779 | + | ||
| 3780 | +sub labs { | ||
| 3781 | + unimpl "labs() is C-specific, use abs instead"; | ||
| 3782 | +} | ||
| 3783 | + | ||
| 3784 | +sub ldiv { | ||
| 3785 | + unimpl "ldiv() is C-specific, use /, % and int instead"; | ||
| 3786 | +} | ||
| 3787 | + | ||
| 3788 | +sub malloc { | ||
| 3789 | + unimpl "malloc() is C-specific, stopped"; | ||
| 3790 | +} | ||
| 3791 | + | ||
| 3792 | +sub qsort { | ||
| 3793 | + unimpl "qsort() is C-specific, use sort instead"; | ||
| 3794 | +} | ||
| 3795 | + | ||
| 3796 | +sub rand { | ||
| 3797 | + unimpl "rand() is non-portable, use Perl's rand instead"; | ||
| 3798 | +} | ||
| 3799 | + | ||
| 3800 | +sub realloc { | ||
| 3801 | + unimpl "realloc() is C-specific, stopped"; | ||
| 3802 | +} | ||
| 3803 | + | ||
| 3804 | +sub srand { | ||
| 3805 | + unimpl "srand()"; | ||
| 3806 | +} | ||
| 3807 | + | ||
| 3808 | +sub system { | ||
| 3809 | + usage "system(command)" if @_ != 1; | ||
| 3810 | + CORE::system($_[0]); | ||
| 3811 | +} | ||
| 3812 | + | ||
| 3813 | +sub memchr { | ||
| 3814 | + unimpl "memchr() is C-specific, use index() instead"; | ||
| 3815 | +} | ||
| 3816 | + | ||
| 3817 | +sub memcmp { | ||
| 3818 | + unimpl "memcmp() is C-specific, use eq instead"; | ||
| 3819 | +} | ||
| 3820 | + | ||
| 3821 | +sub memcpy { | ||
| 3822 | + unimpl "memcpy() is C-specific, use = instead"; | ||
| 3823 | +} | ||
| 3824 | + | ||
| 3825 | +sub memmove { | ||
| 3826 | + unimpl "memmove() is C-specific, use = instead"; | ||
| 3827 | +} | ||
| 3828 | + | ||
| 3829 | +sub memset { | ||
| 3830 | + unimpl "memset() is C-specific, use x instead"; | ||
| 3831 | +} | ||
| 3832 | + | ||
| 3833 | +sub strcat { | ||
| 3834 | + unimpl "strcat() is C-specific, use .= instead"; | ||
| 3835 | +} | ||
| 3836 | + | ||
| 3837 | +sub strchr { | ||
| 3838 | + unimpl "strchr() is C-specific, use index() instead"; | ||
| 3839 | +} | ||
| 3840 | + | ||
| 3841 | +sub strcmp { | ||
| 3842 | + unimpl "strcmp() is C-specific, use eq instead"; | ||
| 3843 | +} | ||
| 3844 | + | ||
| 3845 | +sub strcpy { | ||
| 3846 | + unimpl "strcpy() is C-specific, use = instead"; | ||
| 3847 | +} | ||
| 3848 | + | ||
| 3849 | +sub strcspn { | ||
| 3850 | + unimpl "strcspn() is C-specific, use regular expressions instead"; | ||
| 3851 | +} | ||
| 3852 | + | ||
| 3853 | +sub strerror { | ||
| 3854 | + usage "strerror(errno)" if @_ != 1; | ||
| 3855 | + local $! = $_[0]; | ||
| 3856 | + $! . ""; | ||
| 3857 | +} | ||
| 3858 | + | ||
| 3859 | +sub strlen { | ||
| 3860 | + unimpl "strlen() is C-specific, use length instead"; | ||
| 3861 | +} | ||
| 3862 | + | ||
| 3863 | +sub strncat { | ||
| 3864 | + unimpl "strncat() is C-specific, use .= instead"; | ||
| 3865 | +} | ||
| 3866 | + | ||
| 3867 | +sub strncmp { | ||
| 3868 | + unimpl "strncmp() is C-specific, use eq instead"; | ||
| 3869 | +} | ||
| 3870 | + | ||
| 3871 | +sub strncpy { | ||
| 3872 | + unimpl "strncpy() is C-specific, use = instead"; | ||
| 3873 | +} | ||
| 3874 | + | ||
| 3875 | +sub strpbrk { | ||
| 3876 | + unimpl "strpbrk() is C-specific, stopped"; | ||
| 3877 | +} | ||
| 3878 | + | ||
| 3879 | +sub strrchr { | ||
| 3880 | + unimpl "strrchr() is C-specific, use rindex() instead"; | ||
| 3881 | +} | ||
| 3882 | + | ||
| 3883 | +sub strspn { | ||
| 3884 | + unimpl "strspn() is C-specific, stopped"; | ||
| 3885 | +} | ||
| 3886 | + | ||
| 3887 | +sub strstr { | ||
| 3888 | + usage "strstr(big, little)" if @_ != 2; | ||
| 3889 | + CORE::index($_[0], $_[1]); | ||
| 3890 | +} | ||
| 3891 | + | ||
| 3892 | +sub strtok { | ||
| 3893 | + unimpl "strtok() is C-specific, stopped"; | ||
| 3894 | +} | ||
| 3895 | + | ||
| 3896 | +sub chmod { | ||
| 3897 | + usage "chmod(mode, filename)" if @_ != 2; | ||
| 3898 | + CORE::chmod($_[0], $_[1]); | ||
| 3899 | +} | ||
| 3900 | + | ||
| 3901 | +sub fstat { | ||
| 3902 | + usage "fstat(fd)" if @_ != 1; | ||
| 3903 | + local *TMP; | ||
| 3904 | + CORE::open(TMP, "<&$_[0]"); # Gross. | ||
| 3905 | + my @l = CORE::stat(TMP); | ||
| 3906 | + CORE::close(TMP); | ||
| 3907 | + @l; | ||
| 3908 | +} | ||
| 3909 | + | ||
| 3910 | +sub mkdir { | ||
| 3911 | + usage "mkdir(directoryname, mode)" if @_ != 2; | ||
| 3912 | + CORE::mkdir($_[0], $_[1]); | ||
| 3913 | +} | ||
| 3914 | + | ||
| 3915 | +sub stat { | ||
| 3916 | + usage "stat(filename)" if @_ != 1; | ||
| 3917 | + CORE::stat($_[0]); | ||
| 3918 | +} | ||
| 3919 | + | ||
| 3920 | +sub umask { | ||
| 3921 | + usage "umask(mask)" if @_ != 1; | ||
| 3922 | + CORE::umask($_[0]); | ||
| 3923 | +} | ||
| 3924 | + | ||
| 3925 | +sub wait { | ||
| 3926 | + usage "wait()" if @_ != 0; | ||
| 3927 | + CORE::wait(); | ||
| 3928 | +} | ||
| 3929 | + | ||
| 3930 | +sub waitpid { | ||
| 3931 | + usage "waitpid(pid, options)" if @_ != 2; | ||
| 3932 | + CORE::waitpid($_[0], $_[1]); | ||
| 3933 | +} | ||
| 3934 | + | ||
| 3935 | +sub gmtime { | ||
| 3936 | + usage "gmtime(time)" if @_ != 1; | ||
| 3937 | + CORE::gmtime($_[0]); | ||
| 3938 | +} | ||
| 3939 | + | ||
| 3940 | +sub localtime { | ||
| 3941 | + usage "localtime(time)" if @_ != 1; | ||
| 3942 | + CORE::localtime($_[0]); | ||
| 3943 | +} | ||
| 3944 | + | ||
| 3945 | +sub time { | ||
| 3946 | + usage "time()" if @_ != 0; | ||
| 3947 | + CORE::time; | ||
| 3948 | +} | ||
| 3949 | + | ||
| 3950 | +sub alarm { | ||
| 3951 | + usage "alarm(seconds)" if @_ != 1; | ||
| 3952 | + CORE::alarm($_[0]); | ||
| 3953 | +} | ||
| 3954 | + | ||
| 3955 | +sub chdir { | ||
| 3956 | + usage "chdir(directory)" if @_ != 1; | ||
| 3957 | + CORE::chdir($_[0]); | ||
| 3958 | +} | ||
| 3959 | + | ||
| 3960 | +sub chown { | ||
| 3961 | + usage "chown(uid, gid, filename)" if @_ != 3; | ||
| 3962 | + CORE::chown($_[0], $_[1], $_[2]); | ||
| 3963 | +} | ||
| 3964 | + | ||
| 3965 | +sub execl { | ||
| 3966 | + unimpl "execl() is C-specific, stopped"; | ||
| 3967 | +} | ||
| 3968 | + | ||
| 3969 | +sub execle { | ||
| 3970 | + unimpl "execle() is C-specific, stopped"; | ||
| 3971 | +} | ||
| 3972 | + | ||
| 3973 | +sub execlp { | ||
| 3974 | + unimpl "execlp() is C-specific, stopped"; | ||
| 3975 | +} | ||
| 3976 | + | ||
| 3977 | +sub execv { | ||
| 3978 | + unimpl "execv() is C-specific, stopped"; | ||
| 3979 | +} | ||
| 3980 | + | ||
| 3981 | +sub execve { | ||
| 3982 | + unimpl "execve() is C-specific, stopped"; | ||
| 3983 | +} | ||
| 3984 | + | ||
| 3985 | +sub execvp { | ||
| 3986 | + unimpl "execvp() is C-specific, stopped"; | ||
| 3987 | +} | ||
| 3988 | + | ||
| 3989 | +sub fork { | ||
| 3990 | + usage "fork()" if @_ != 0; | ||
| 3991 | + CORE::fork; | ||
| 3992 | +} | ||
| 3993 | + | ||
| 3994 | +sub getegid { | ||
| 3995 | + usage "getegid()" if @_ != 0; | ||
| 3996 | + $) + 0; | ||
| 3997 | +} | ||
| 3998 | + | ||
| 3999 | +sub geteuid { | ||
| 4000 | + usage "geteuid()" if @_ != 0; | ||
| 4001 | + $> + 0; | ||
| 4002 | +} | ||
| 4003 | + | ||
| 4004 | +sub getgid { | ||
| 4005 | + usage "getgid()" if @_ != 0; | ||
| 4006 | + $( + 0; | ||
| 4007 | +} | ||
| 4008 | + | ||
| 4009 | +sub getgroups { | ||
| 4010 | + usage "getgroups()" if @_ != 0; | ||
| 4011 | + my %seen; | ||
| 4012 | + grep(!$seen{$_}++, split(' ', $) )); | ||
| 4013 | +} | ||
| 4014 | + | ||
| 4015 | +sub getlogin { | ||
| 4016 | + usage "getlogin()" if @_ != 0; | ||
| 4017 | + CORE::getlogin(); | ||
| 4018 | +} | ||
| 4019 | + | ||
| 4020 | +sub getpgrp { | ||
| 4021 | + usage "getpgrp()" if @_ != 0; | ||
| 4022 | + CORE::getpgrp; | ||
| 4023 | +} | ||
| 4024 | + | ||
| 4025 | +sub getpid { | ||
| 4026 | + usage "getpid()" if @_ != 0; | ||
| 4027 | + $$; | ||
| 4028 | +} | ||
| 4029 | + | ||
| 4030 | +sub getppid { | ||
| 4031 | + usage "getppid()" if @_ != 0; | ||
| 4032 | + CORE::getppid; | ||
| 4033 | +} | ||
| 4034 | + | ||
| 4035 | +sub getuid { | ||
| 4036 | + usage "getuid()" if @_ != 0; | ||
| 4037 | + $<; | ||
| 4038 | +} | ||
| 4039 | + | ||
| 4040 | +sub isatty { | ||
| 4041 | + usage "isatty(filehandle)" if @_ != 1; | ||
| 4042 | + -t $_[0]; | ||
| 4043 | +} | ||
| 4044 | + | ||
| 4045 | +sub link { | ||
| 4046 | + usage "link(oldfilename, newfilename)" if @_ != 2; | ||
| 4047 | + CORE::link($_[0], $_[1]); | ||
| 4048 | +} | ||
| 4049 | + | ||
| 4050 | +sub rmdir { | ||
| 4051 | + usage "rmdir(directoryname)" if @_ != 1; | ||
| 4052 | + CORE::rmdir($_[0]); | ||
| 4053 | +} | ||
| 4054 | + | ||
| 4055 | +sub setbuf { | ||
| 4056 | + redef "IO::Handle::setbuf()"; | ||
| 4057 | +} | ||
| 4058 | + | ||
| 4059 | +sub setvbuf { | ||
| 4060 | + redef "IO::Handle::setvbuf()"; | ||
| 4061 | +} | ||
| 4062 | + | ||
| 4063 | +sub sleep { | ||
| 4064 | + usage "sleep(seconds)" if @_ != 1; | ||
| 4065 | + $_[0] - CORE::sleep($_[0]); | ||
| 4066 | +} | ||
| 4067 | + | ||
| 4068 | +sub unlink { | ||
| 4069 | + usage "unlink(filename)" if @_ != 1; | ||
| 4070 | + CORE::unlink($_[0]); | ||
| 4071 | +} | ||
| 4072 | + | ||
| 4073 | +sub utime { | ||
| 4074 | + usage "utime(filename, atime, mtime)" if @_ != 3; | ||
| 4075 | + CORE::utime($_[1], $_[2], $_[0]); | ||
| 4076 | +} | ||
| 4077 | + | ||
| 4078 | +sub load_imports { | ||
| 4079 | +%EXPORT_TAGS = ( | ||
| 4080 | + | ||
| 4081 | + assert_h => [qw(assert NDEBUG)], | ||
| 4082 | + | ||
| 4083 | + ctype_h => [qw(isalnum isalpha iscntrl isdigit isgraph islower | ||
| 4084 | + isprint ispunct isspace isupper isxdigit tolower toupper)], | ||
| 4085 | + | ||
| 4086 | + dirent_h => [], | ||
| 4087 | + | ||
| 4088 | + errno_h => [qw(E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT | ||
| 4089 | + EAGAIN EALREADY EBADF EBUSY ECHILD ECONNABORTED | ||
| 4090 | + ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDOM EDQUOT | ||
| 4091 | + EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH EINPROGRESS | ||
| 4092 | + EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK | ||
| 4093 | + EMSGSIZE ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH | ||
| 4094 | + ENFILE ENOBUFS ENODEV ENOENT ENOEXEC ENOLCK ENOMEM | ||
| 4095 | + ENOPROTOOPT ENOSPC ENOSYS ENOTBLK ENOTCONN ENOTDIR | ||
| 4096 | + ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM | ||
| 4097 | + EPFNOSUPPORT EPIPE EPROCLIM EPROTONOSUPPORT EPROTOTYPE | ||
| 4098 | + ERANGE EREMOTE ERESTART EROFS ESHUTDOWN ESOCKTNOSUPPORT | ||
| 4099 | + ESPIPE ESRCH ESTALE ETIMEDOUT ETOOMANYREFS ETXTBSY | ||
| 4100 | + EUSERS EWOULDBLOCK EXDEV errno)], | ||
| 4101 | + | ||
| 4102 | + fcntl_h => [qw(FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK | ||
| 4103 | + F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK | ||
| 4104 | + O_ACCMODE O_APPEND O_CREAT O_EXCL O_NOCTTY O_NONBLOCK | ||
| 4105 | + O_RDONLY O_RDWR O_TRUNC O_WRONLY | ||
| 4106 | + creat | ||
| 4107 | + SEEK_CUR SEEK_END SEEK_SET | ||
| 4108 | + S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU | ||
| 4109 | + S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG S_ISUID | ||
| 4110 | + S_IWGRP S_IWOTH S_IWUSR)], | ||
| 4111 | + | ||
| 4112 | + float_h => [qw(DBL_DIG DBL_EPSILON DBL_MANT_DIG | ||
| 4113 | + DBL_MAX DBL_MAX_10_EXP DBL_MAX_EXP | ||
| 4114 | + DBL_MIN DBL_MIN_10_EXP DBL_MIN_EXP | ||
| 4115 | + FLT_DIG FLT_EPSILON FLT_MANT_DIG | ||
| 4116 | + FLT_MAX FLT_MAX_10_EXP FLT_MAX_EXP | ||
| 4117 | + FLT_MIN FLT_MIN_10_EXP FLT_MIN_EXP | ||
| 4118 | + FLT_RADIX FLT_ROUNDS | ||
| 4119 | + LDBL_DIG LDBL_EPSILON LDBL_MANT_DIG | ||
| 4120 | + LDBL_MAX LDBL_MAX_10_EXP LDBL_MAX_EXP | ||
| 4121 | + LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP)], | ||
| 4122 | + | ||
| 4123 | + grp_h => [], | ||
| 4124 | + | ||
| 4125 | + limits_h => [qw( ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX | ||
| 4126 | + INT_MAX INT_MIN LINK_MAX LONG_MAX LONG_MIN MAX_CANON | ||
| 4127 | + MAX_INPUT MB_LEN_MAX NAME_MAX NGROUPS_MAX OPEN_MAX | ||
| 4128 | + PATH_MAX PIPE_BUF SCHAR_MAX SCHAR_MIN SHRT_MAX SHRT_MIN | ||
| 4129 | + SSIZE_MAX STREAM_MAX TZNAME_MAX UCHAR_MAX UINT_MAX | ||
| 4130 | + ULONG_MAX USHRT_MAX _POSIX_ARG_MAX _POSIX_CHILD_MAX | ||
| 4131 | + _POSIX_LINK_MAX _POSIX_MAX_CANON _POSIX_MAX_INPUT | ||
| 4132 | + _POSIX_NAME_MAX _POSIX_NGROUPS_MAX _POSIX_OPEN_MAX | ||
| 4133 | + _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_SSIZE_MAX | ||
| 4134 | + _POSIX_STREAM_MAX _POSIX_TZNAME_MAX)], | ||
| 4135 | + | ||
| 4136 | + locale_h => [qw(LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES | ||
| 4137 | + LC_MONETARY LC_NUMERIC LC_TIME NULL | ||
| 4138 | + localeconv setlocale)], | ||
| 4139 | + | ||
| 4140 | + math_h => [qw(HUGE_VAL acos asin atan ceil cosh fabs floor fmod | ||
| 4141 | + frexp ldexp log10 modf pow sinh tan tanh)], | ||
| 4142 | + | ||
| 4143 | + pwd_h => [], | ||
| 4144 | + | ||
| 4145 | + setjmp_h => [qw(longjmp setjmp siglongjmp sigsetjmp)], | ||
| 4146 | + | ||
| 4147 | + signal_h => [qw(SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK | ||
| 4148 | + SA_RESETHAND SA_RESTART SA_SIGINFO SIGABRT SIGALRM | ||
| 4149 | + SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL | ||
| 4150 | + SIGPIPE %SIGRT SIGRTMIN SIGRTMAX SIGQUIT SIGSEGV SIGSTOP | ||
| 4151 | + SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 | ||
| 4152 | + SIG_BLOCK SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK SIG_UNBLOCK | ||
| 4153 | + raise sigaction signal sigpending sigprocmask sigsuspend)], | ||
| 4154 | + | ||
| 4155 | + stdarg_h => [], | ||
| 4156 | + | ||
| 4157 | + stddef_h => [qw(NULL offsetof)], | ||
| 4158 | + | ||
| 4159 | + stdio_h => [qw(BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid | ||
| 4160 | + L_tmpname NULL SEEK_CUR SEEK_END SEEK_SET | ||
| 4161 | + STREAM_MAX TMP_MAX stderr stdin stdout | ||
| 4162 | + clearerr fclose fdopen feof ferror fflush fgetc fgetpos | ||
| 4163 | + fgets fopen fprintf fputc fputs fread freopen | ||
| 4164 | + fscanf fseek fsetpos ftell fwrite getchar gets | ||
| 4165 | + perror putc putchar puts remove rewind | ||
| 4166 | + scanf setbuf setvbuf sscanf tmpfile tmpnam | ||
| 4167 | + ungetc vfprintf vprintf vsprintf)], | ||
| 4168 | + | ||
| 4169 | + stdlib_h => [qw(EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX NULL RAND_MAX | ||
| 4170 | + abort atexit atof atoi atol bsearch calloc div | ||
| 4171 | + free getenv labs ldiv malloc mblen mbstowcs mbtowc | ||
| 4172 | + qsort realloc strtod strtol strtoul wcstombs wctomb)], | ||
| 4173 | + | ||
| 4174 | + string_h => [qw(NULL memchr memcmp memcpy memmove memset strcat | ||
| 4175 | + strchr strcmp strcoll strcpy strcspn strerror strlen | ||
| 4176 | + strncat strncmp strncpy strpbrk strrchr strspn strstr | ||
| 4177 | + strtok strxfrm)], | ||
| 4178 | + | ||
| 4179 | + sys_stat_h => [qw(S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU | ||
| 4180 | + S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG | ||
| 4181 | + S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR | ||
| 4182 | + fstat mkfifo)], | ||
| 4183 | + | ||
| 4184 | + sys_times_h => [], | ||
| 4185 | + | ||
| 4186 | + sys_types_h => [], | ||
| 4187 | + | ||
| 4188 | + sys_utsname_h => [qw(uname)], | ||
| 4189 | + | ||
| 4190 | + sys_wait_h => [qw(WEXITSTATUS WIFEXITED WIFSIGNALED WIFSTOPPED | ||
| 4191 | + WNOHANG WSTOPSIG WTERMSIG WUNTRACED)], | ||
| 4192 | + | ||
| 4193 | + termios_h => [qw( B0 B110 B1200 B134 B150 B1800 B19200 B200 B2400 | ||
| 4194 | + B300 B38400 B4800 B50 B600 B75 B9600 BRKINT CLOCAL | ||
| 4195 | + CREAD CS5 CS6 CS7 CS8 CSIZE CSTOPB ECHO ECHOE ECHOK | ||
| 4196 | + ECHONL HUPCL ICANON ICRNL IEXTEN IGNBRK IGNCR IGNPAR | ||
| 4197 | + INLCR INPCK ISIG ISTRIP IXOFF IXON NCCS NOFLSH OPOST | ||
| 4198 | + PARENB PARMRK PARODD TCIFLUSH TCIOFF TCIOFLUSH TCION | ||
| 4199 | + TCOFLUSH TCOOFF TCOON TCSADRAIN TCSAFLUSH TCSANOW | ||
| 4200 | + TOSTOP VEOF VEOL VERASE VINTR VKILL VMIN VQUIT VSTART | ||
| 4201 | + VSTOP VSUSP VTIME | ||
| 4202 | + cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcdrain | ||
| 4203 | + tcflow tcflush tcgetattr tcsendbreak tcsetattr )], | ||
| 4204 | + | ||
| 4205 | + time_h => [qw(CLK_TCK CLOCKS_PER_SEC NULL asctime clock ctime | ||
| 4206 | + difftime mktime strftime tzset tzname)], | ||
| 4207 | + | ||
| 4208 | + unistd_h => [qw(F_OK NULL R_OK SEEK_CUR SEEK_END SEEK_SET | ||
| 4209 | + STDERR_FILENO STDIN_FILENO STDOUT_FILENO W_OK X_OK | ||
| 4210 | + _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON | ||
| 4211 | + _PC_MAX_INPUT _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX | ||
| 4212 | + _PC_PIPE_BUF _PC_VDISABLE _POSIX_CHOWN_RESTRICTED | ||
| 4213 | + _POSIX_JOB_CONTROL _POSIX_NO_TRUNC _POSIX_SAVED_IDS | ||
| 4214 | + _POSIX_VDISABLE _POSIX_VERSION _SC_ARG_MAX | ||
| 4215 | + _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL | ||
| 4216 | + _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_PAGESIZE _SC_SAVED_IDS | ||
| 4217 | + _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION | ||
| 4218 | + _exit access ctermid cuserid | ||
| 4219 | + dup2 dup execl execle execlp execv execve execvp | ||
| 4220 | + fpathconf fsync getcwd getegid geteuid getgid getgroups | ||
| 4221 | + getpid getuid isatty lseek pathconf pause setgid setpgid | ||
| 4222 | + setsid setuid sysconf tcgetpgrp tcsetpgrp ttyname)], | ||
| 4223 | + | ||
| 4224 | + utime_h => [], | ||
| 4225 | + | ||
| 4226 | +); | ||
| 4227 | + | ||
| 4228 | +# Exporter::export_tags(); | ||
| 4229 | +{ | ||
| 4230 | + # De-duplicate the export list: | ||
| 4231 | + my %export; | ||
| 4232 | + @export{map {@$_} values %EXPORT_TAGS} = (); | ||
| 4233 | + # Doing the de-dup with a temporary hash has the advantage that the SVs in | ||
| 4234 | + # @EXPORT are actually shared hash key sacalars, which will save some memory. | ||
| 4235 | + push @EXPORT, keys %export; | ||
| 4236 | +} | ||
| 4237 | + | ||
| 4238 | +@EXPORT_OK = qw( | ||
| 4239 | + abs | ||
| 4240 | + alarm | ||
| 4241 | + atan2 | ||
| 4242 | + chdir | ||
| 4243 | + chmod | ||
| 4244 | + chown | ||
| 4245 | + close | ||
| 4246 | + closedir | ||
| 4247 | + cos | ||
| 4248 | + exit | ||
| 4249 | + exp | ||
| 4250 | + fcntl | ||
| 4251 | + fileno | ||
| 4252 | + fork | ||
| 4253 | + getc | ||
| 4254 | + getgrgid | ||
| 4255 | + getgrnam | ||
| 4256 | + getlogin | ||
| 4257 | + getpgrp | ||
| 4258 | + getppid | ||
| 4259 | + getpwnam | ||
| 4260 | + getpwuid | ||
| 4261 | + gmtime | ||
| 4262 | + isatty | ||
| 4263 | + kill | ||
| 4264 | + lchown | ||
| 4265 | + link | ||
| 4266 | + localtime | ||
| 4267 | + log | ||
| 4268 | + mkdir | ||
| 4269 | + nice | ||
| 4270 | + open | ||
| 4271 | + opendir | ||
| 4272 | + pipe | ||
| 4273 | + printf | ||
| 4274 | + rand | ||
| 4275 | + read | ||
| 4276 | + readdir | ||
| 4277 | + rename | ||
| 4278 | + rewinddir | ||
| 4279 | + rmdir | ||
| 4280 | + sin | ||
| 4281 | + sleep | ||
| 4282 | + sprintf | ||
| 4283 | + sqrt | ||
| 4284 | + srand | ||
| 4285 | + stat | ||
| 4286 | + system | ||
| 4287 | + time | ||
| 4288 | + times | ||
| 4289 | + umask | ||
| 4290 | + unlink | ||
| 4291 | + utime | ||
| 4292 | + wait | ||
| 4293 | + waitpid | ||
| 4294 | + write | ||
| 4295 | +); | ||
| 4296 | + | ||
| 4297 | +require Exporter; | ||
| 4298 | +} | ||
| 4299 | + | ||
| 4300 | +package POSIX::SigAction; | ||
| 4301 | + | ||
| 4302 | +sub new { bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0, SAFE => 0}, $_[0] } | ||
| 4303 | +sub handler { $_[0]->{HANDLER} = $_[1] if @_ > 1; $_[0]->{HANDLER} }; | ||
| 4304 | +sub mask { $_[0]->{MASK} = $_[1] if @_ > 1; $_[0]->{MASK} }; | ||
| 4305 | +sub flags { $_[0]->{FLAGS} = $_[1] if @_ > 1; $_[0]->{FLAGS} }; | ||
| 4306 | +sub safe { $_[0]->{SAFE} = $_[1] if @_ > 1; $_[0]->{SAFE} }; | ||
| 4307 | + | ||
| 4308 | +package POSIX::SigRt; | ||
| 4309 | + | ||
| 4310 | + | ||
| 4311 | +sub _init { | ||
| 4312 | + $_SIGRTMIN = &POSIX::SIGRTMIN; | ||
| 4313 | + $_SIGRTMAX = &POSIX::SIGRTMAX; | ||
| 4314 | + $_sigrtn = $_SIGRTMAX - $_SIGRTMIN; | ||
| 4315 | +} | ||
| 4316 | + | ||
| 4317 | +sub _croak { | ||
| 4318 | + &_init unless defined $_sigrtn; | ||
| 4319 | + die "POSIX::SigRt not available" unless defined $_sigrtn && $_sigrtn > 0; | ||
| 4320 | +} | ||
| 4321 | + | ||
| 4322 | +sub _getsig { | ||
| 4323 | + &_croak; | ||
| 4324 | + my $rtsig = $_[0]; | ||
| 4325 | + # Allow (SIGRT)?MIN( + n)?, a common idiom when doing these things in C. | ||
| 4326 | + $rtsig = $_SIGRTMIN + ($1 || 0) | ||
| 4327 | + if $rtsig =~ /^(?:(?:SIG)?RT)?MIN(\s*\+\s*(\d+))?$/; | ||
| 4328 | + return $rtsig; | ||
| 4329 | +} | ||
| 4330 | + | ||
| 4331 | +sub _exist { | ||
| 4332 | + my $rtsig = _getsig($_[1]); | ||
| 4333 | + my $ok = $rtsig >= $_SIGRTMIN && $rtsig <= $_SIGRTMAX; | ||
| 4334 | + ($rtsig, $ok); | ||
| 4335 | +} | ||
| 4336 | + | ||
| 4337 | +sub _check { | ||
| 4338 | + my ($rtsig, $ok) = &_exist; | ||
| 4339 | + die "No POSIX::SigRt signal $_[1] (valid range SIGRTMIN..SIGRTMAX, or $_SIGRTMIN..$_SIGRTMAX)" | ||
| 4340 | + unless $ok; | ||
| 4341 | + return $rtsig; | ||
| 4342 | +} | ||
| 4343 | + | ||
| 4344 | +sub new { | ||
| 4345 | + my ($rtsig, $handler, $flags) = @_; | ||
| 4346 | + my $sigset = POSIX::SigSet->new($rtsig); | ||
| 4347 | + my $sigact = POSIX::SigAction->new($handler, | ||
| 4348 | + $sigset, | ||
| 4349 | + $flags); | ||
| 4350 | + POSIX::sigaction($rtsig, $sigact); | ||
| 4351 | +} | ||
| 4352 | + | ||
| 4353 | +sub EXISTS { &_exist } | ||
| 4354 | +sub FETCH { my $rtsig = &_check; | ||
| 4355 | + my $oa = POSIX::SigAction->new(); | ||
| 4356 | + POSIX::sigaction($rtsig, undef, $oa); | ||
| 4357 | + return $oa->{HANDLER} } | ||
| 4358 | +sub STORE { my $rtsig = &_check; new($rtsig, $_[2], $SIGACTION_FLAGS) } | ||
| 4359 | +sub DELETE { delete $SIG{ &_check } } | ||
| 4360 | +sub CLEAR { &_exist; delete @SIG{ &POSIX::SIGRTMIN .. &POSIX::SIGRTMAX } } | ||
| 4361 | +sub SCALAR { &_croak; $_sigrtn + 1 } | ||
| 4362 | diff --git a/ext/POSIX/lib/POSIX.pod b/ext/POSIX/lib/POSIX.pod | ||
| 4363 | new file mode 100644 | ||
| 4364 | index 0000000..64852e9 | ||
| 4365 | --- /dev/null | ||
| 4366 | +++ b/ext/POSIX/lib/POSIX.pod | ||
| 4367 | @@ -0,0 +1,2218 @@ | ||
| 4368 | +=head1 NAME | ||
| 4369 | + | ||
| 4370 | +POSIX - Perl interface to IEEE Std 1003.1 | ||
| 4371 | + | ||
| 4372 | +=head1 SYNOPSIS | ||
| 4373 | + | ||
| 4374 | + use POSIX; | ||
| 4375 | + use POSIX qw(setsid); | ||
| 4376 | + use POSIX qw(:errno_h :fcntl_h); | ||
| 4377 | + | ||
| 4378 | + printf "EINTR is %d\n", EINTR; | ||
| 4379 | + | ||
| 4380 | + $sess_id = POSIX::setsid(); | ||
| 4381 | + | ||
| 4382 | + $fd = POSIX::open($path, O_CREAT|O_EXCL|O_WRONLY, 0644); | ||
| 4383 | + # note: that's a filedescriptor, *NOT* a filehandle | ||
| 4384 | + | ||
| 4385 | +=head1 DESCRIPTION | ||
| 4386 | + | ||
| 4387 | +The POSIX module permits you to access all (or nearly all) the standard | ||
| 4388 | +POSIX 1003.1 identifiers. Many of these identifiers have been given Perl-ish | ||
| 4389 | +interfaces. | ||
| 4390 | + | ||
| 4391 | +I<Everything is exported by default> with the exception of any POSIX | ||
| 4392 | +functions with the same name as a built-in Perl function, such as | ||
| 4393 | +C<abs>, C<alarm>, C<rmdir>, C<write>, etc.., which will be exported | ||
| 4394 | +only if you ask for them explicitly. This is an unfortunate backwards | ||
| 4395 | +compatibility feature. You can stop the exporting by saying C<use | ||
| 4396 | +POSIX ()> and then use the fully qualified names (ie. C<POSIX::SEEK_END>). | ||
| 4397 | + | ||
| 4398 | +This document gives a condensed list of the features available in the POSIX | ||
| 4399 | +module. Consult your operating system's manpages for general information on | ||
| 4400 | +most features. Consult L<perlfunc> for functions which are noted as being | ||
| 4401 | +identical to Perl's builtin functions. | ||
| 4402 | + | ||
| 4403 | +The first section describes POSIX functions from the 1003.1 specification. | ||
| 4404 | +The second section describes some classes for signal objects, TTY objects, | ||
| 4405 | +and other miscellaneous objects. The remaining sections list various | ||
| 4406 | +constants and macros in an organization which roughly follows IEEE Std | ||
| 4407 | +1003.1b-1993. | ||
| 4408 | + | ||
| 4409 | +=head1 NOTE | ||
| 4410 | + | ||
| 4411 | +The POSIX module is probably the most complex Perl module supplied with | ||
| 4412 | +the standard distribution. It incorporates autoloading, namespace games, | ||
| 4413 | +and dynamic loading of code that's in Perl, C, or both. It's a great | ||
| 4414 | +source of wisdom. | ||
| 4415 | + | ||
| 4416 | +=head1 CAVEATS | ||
| 4417 | + | ||
| 4418 | +A few functions are not implemented because they are C specific. If you | ||
| 4419 | +attempt to call these, they will print a message telling you that they | ||
| 4420 | +aren't implemented, and suggest using the Perl equivalent should one | ||
| 4421 | +exist. For example, trying to access the setjmp() call will elicit the | ||
| 4422 | +message "setjmp() is C-specific: use eval {} instead". | ||
| 4423 | + | ||
| 4424 | +Furthermore, some evil vendors will claim 1003.1 compliance, but in fact | ||
| 4425 | +are not so: they will not pass the PCTS (POSIX Compliance Test Suites). | ||
| 4426 | +For example, one vendor may not define EDEADLK, or the semantics of the | ||
| 4427 | +errno values set by open(2) might not be quite right. Perl does not | ||
| 4428 | +attempt to verify POSIX compliance. That means you can currently | ||
| 4429 | +successfully say "use POSIX", and then later in your program you find | ||
| 4430 | +that your vendor has been lax and there's no usable ICANON macro after | ||
| 4431 | +all. This could be construed to be a bug. | ||
| 4432 | + | ||
| 4433 | +=head1 FUNCTIONS | ||
| 4434 | + | ||
| 4435 | +=over 8 | ||
| 4436 | + | ||
| 4437 | +=item _exit | ||
| 4438 | + | ||
| 4439 | +This is identical to the C function C<_exit()>. It exits the program | ||
| 4440 | +immediately which means among other things buffered I/O is B<not> flushed. | ||
| 4441 | + | ||
| 4442 | +Note that when using threads and in Linux this is B<not> a good way to | ||
| 4443 | +exit a thread because in Linux processes and threads are kind of the | ||
| 4444 | +same thing (Note: while this is the situation in early 2003 there are | ||
| 4445 | +projects under way to have threads with more POSIXly semantics in Linux). | ||
| 4446 | +If you want not to return from a thread, detach the thread. | ||
| 4447 | + | ||
| 4448 | +=item abort | ||
| 4449 | + | ||
| 4450 | +This is identical to the C function C<abort()>. It terminates the | ||
| 4451 | +process with a C<SIGABRT> signal unless caught by a signal handler or | ||
| 4452 | +if the handler does not return normally (it e.g. does a C<longjmp>). | ||
| 4453 | + | ||
| 4454 | +=item abs | ||
| 4455 | + | ||
| 4456 | +This is identical to Perl's builtin C<abs()> function, returning | ||
| 4457 | +the absolute value of its numerical argument. | ||
| 4458 | + | ||
| 4459 | +=item access | ||
| 4460 | + | ||
| 4461 | +Determines the accessibility of a file. | ||
| 4462 | + | ||
| 4463 | + if( POSIX::access( "/", &POSIX::R_OK ) ){ | ||
| 4464 | + print "have read permission\n"; | ||
| 4465 | + } | ||
| 4466 | + | ||
| 4467 | +Returns C<undef> on failure. Note: do not use C<access()> for | ||
| 4468 | +security purposes. Between the C<access()> call and the operation | ||
| 4469 | +you are preparing for the permissions might change: a classic | ||
| 4470 | +I<race condition>. | ||
| 4471 | + | ||
| 4472 | +=item acos | ||
| 4473 | + | ||
| 4474 | +This is identical to the C function C<acos()>, returning | ||
| 4475 | +the arcus cosine of its numerical argument. See also L<Math::Trig>. | ||
| 4476 | + | ||
| 4477 | +=item alarm | ||
| 4478 | + | ||
| 4479 | +This is identical to Perl's builtin C<alarm()> function, | ||
| 4480 | +either for arming or disarming the C<SIGARLM> timer. | ||
| 4481 | + | ||
| 4482 | +=item asctime | ||
| 4483 | + | ||
| 4484 | +This is identical to the C function C<asctime()>. It returns | ||
| 4485 | +a string of the form | ||
| 4486 | + | ||
| 4487 | + "Fri Jun 2 18:22:13 2000\n\0" | ||
| 4488 | + | ||
| 4489 | +and it is called thusly | ||
| 4490 | + | ||
| 4491 | + $asctime = asctime($sec, $min, $hour, $mday, $mon, $year, | ||
| 4492 | + $wday, $yday, $isdst); | ||
| 4493 | + | ||
| 4494 | +The C<$mon> is zero-based: January equals C<0>. The C<$year> is | ||
| 4495 | +1900-based: 2001 equals C<101>. C<$wday> and C<$yday> default to zero | ||
| 4496 | +(and are usually ignored anyway), and C<$isdst> defaults to -1. | ||
| 4497 | + | ||
| 4498 | +=item asin | ||
| 4499 | + | ||
| 4500 | +This is identical to the C function C<asin()>, returning | ||
| 4501 | +the arcus sine of its numerical argument. See also L<Math::Trig>. | ||
| 4502 | + | ||
| 4503 | +=item assert | ||
| 4504 | + | ||
| 4505 | +Unimplemented, but you can use L<perlfunc/die> and the L<Carp> module | ||
| 4506 | +to achieve similar things. | ||
| 4507 | + | ||
| 4508 | +=item atan | ||
| 4509 | + | ||
| 4510 | +This is identical to the C function C<atan()>, returning the | ||
| 4511 | +arcus tangent of its numerical argument. See also L<Math::Trig>. | ||
| 4512 | + | ||
| 4513 | +=item atan2 | ||
| 4514 | + | ||
| 4515 | +This is identical to Perl's builtin C<atan2()> function, returning | ||
| 4516 | +the arcus tangent defined by its two numerical arguments, the I<y> | ||
| 4517 | +coordinate and the I<x> coordinate. See also L<Math::Trig>. | ||
| 4518 | + | ||
| 4519 | +=item atexit | ||
| 4520 | + | ||
| 4521 | +atexit() is C-specific: use C<END {}> instead, see L<perlsub>. | ||
| 4522 | + | ||
| 4523 | +=item atof | ||
| 4524 | + | ||
| 4525 | +atof() is C-specific. Perl converts strings to numbers transparently. | ||
| 4526 | +If you need to force a scalar to a number, add a zero to it. | ||
| 4527 | + | ||
| 4528 | +=item atoi | ||
| 4529 | + | ||
| 4530 | +atoi() is C-specific. Perl converts strings to numbers transparently. | ||
| 4531 | +If you need to force a scalar to a number, add a zero to it. | ||
| 4532 | +If you need to have just the integer part, see L<perlfunc/int>. | ||
| 4533 | + | ||
| 4534 | +=item atol | ||
| 4535 | + | ||
| 4536 | +atol() is C-specific. Perl converts strings to numbers transparently. | ||
| 4537 | +If you need to force a scalar to a number, add a zero to it. | ||
| 4538 | +If you need to have just the integer part, see L<perlfunc/int>. | ||
| 4539 | + | ||
| 4540 | +=item bsearch | ||
| 4541 | + | ||
| 4542 | +bsearch() not supplied. For doing binary search on wordlists, | ||
| 4543 | +see L<Search::Dict>. | ||
| 4544 | + | ||
| 4545 | +=item calloc | ||
| 4546 | + | ||
| 4547 | +calloc() is C-specific. Perl does memory management transparently. | ||
| 4548 | + | ||
| 4549 | +=item ceil | ||
| 4550 | + | ||
| 4551 | +This is identical to the C function C<ceil()>, returning the smallest | ||
| 4552 | +integer value greater than or equal to the given numerical argument. | ||
| 4553 | + | ||
| 4554 | +=item chdir | ||
| 4555 | + | ||
| 4556 | +This is identical to Perl's builtin C<chdir()> function, allowing | ||
| 4557 | +one to change the working (default) directory, see L<perlfunc/chdir>. | ||
| 4558 | + | ||
| 4559 | +=item chmod | ||
| 4560 | + | ||
| 4561 | +This is identical to Perl's builtin C<chmod()> function, allowing | ||
| 4562 | +one to change file and directory permissions, see L<perlfunc/chmod>. | ||
| 4563 | + | ||
| 4564 | +=item chown | ||
| 4565 | + | ||
| 4566 | +This is identical to Perl's builtin C<chown()> function, allowing one | ||
| 4567 | +to change file and directory owners and groups, see L<perlfunc/chown>. | ||
| 4568 | + | ||
| 4569 | +=item clearerr | ||
| 4570 | + | ||
| 4571 | +Use the method C<IO::Handle::clearerr()> instead, to reset the error | ||
| 4572 | +state (if any) and EOF state (if any) of the given stream. | ||
| 4573 | + | ||
| 4574 | +=item clock | ||
| 4575 | + | ||
| 4576 | +This is identical to the C function C<clock()>, returning the | ||
| 4577 | +amount of spent processor time in microseconds. | ||
| 4578 | + | ||
| 4579 | +=item close | ||
| 4580 | + | ||
| 4581 | +Close the file. This uses file descriptors such as those obtained by calling | ||
| 4582 | +C<POSIX::open>. | ||
| 4583 | + | ||
| 4584 | + $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); | ||
| 4585 | + POSIX::close( $fd ); | ||
| 4586 | + | ||
| 4587 | +Returns C<undef> on failure. | ||
| 4588 | + | ||
| 4589 | +See also L<perlfunc/close>. | ||
| 4590 | + | ||
| 4591 | +=item closedir | ||
| 4592 | + | ||
| 4593 | +This is identical to Perl's builtin C<closedir()> function for closing | ||
| 4594 | +a directory handle, see L<perlfunc/closedir>. | ||
| 4595 | + | ||
| 4596 | +=item cos | ||
| 4597 | + | ||
| 4598 | +This is identical to Perl's builtin C<cos()> function, for returning | ||
| 4599 | +the cosine of its numerical argument, see L<perlfunc/cos>. | ||
| 4600 | +See also L<Math::Trig>. | ||
| 4601 | + | ||
| 4602 | +=item cosh | ||
| 4603 | + | ||
| 4604 | +This is identical to the C function C<cosh()>, for returning | ||
| 4605 | +the hyperbolic cosine of its numeric argument. See also L<Math::Trig>. | ||
| 4606 | + | ||
| 4607 | +=item creat | ||
| 4608 | + | ||
| 4609 | +Create a new file. This returns a file descriptor like the ones returned by | ||
| 4610 | +C<POSIX::open>. Use C<POSIX::close> to close the file. | ||
| 4611 | + | ||
| 4612 | + $fd = POSIX::creat( "foo", 0611 ); | ||
| 4613 | + POSIX::close( $fd ); | ||
| 4614 | + | ||
| 4615 | +See also L<perlfunc/sysopen> and its C<O_CREAT> flag. | ||
| 4616 | + | ||
| 4617 | +=item ctermid | ||
| 4618 | + | ||
| 4619 | +Generates the path name for the controlling terminal. | ||
| 4620 | + | ||
| 4621 | + $path = POSIX::ctermid(); | ||
| 4622 | + | ||
| 4623 | +=item ctime | ||
| 4624 | + | ||
| 4625 | +This is identical to the C function C<ctime()> and equivalent | ||
| 4626 | +to C<asctime(localtime(...))>, see L</asctime> and L</localtime>. | ||
| 4627 | + | ||
| 4628 | +=item cuserid | ||
| 4629 | + | ||
| 4630 | +Get the login name of the owner of the current process. | ||
| 4631 | + | ||
| 4632 | + $name = POSIX::cuserid(); | ||
| 4633 | + | ||
| 4634 | +=item difftime | ||
| 4635 | + | ||
| 4636 | +This is identical to the C function C<difftime()>, for returning | ||
| 4637 | +the time difference (in seconds) between two times (as returned | ||
| 4638 | +by C<time()>), see L</time>. | ||
| 4639 | + | ||
| 4640 | +=item div | ||
| 4641 | + | ||
| 4642 | +div() is C-specific, use L<perlfunc/int> on the usual C</> division and | ||
| 4643 | +the modulus C<%>. | ||
| 4644 | + | ||
| 4645 | +=item dup | ||
| 4646 | + | ||
| 4647 | +This is similar to the C function C<dup()>, for duplicating a file | ||
| 4648 | +descriptor. | ||
| 4649 | + | ||
| 4650 | +This uses file descriptors such as those obtained by calling | ||
| 4651 | +C<POSIX::open>. | ||
| 4652 | + | ||
| 4653 | +Returns C<undef> on failure. | ||
| 4654 | + | ||
| 4655 | +=item dup2 | ||
| 4656 | + | ||
| 4657 | +This is similar to the C function C<dup2()>, for duplicating a file | ||
| 4658 | +descriptor to an another known file descriptor. | ||
| 4659 | + | ||
| 4660 | +This uses file descriptors such as those obtained by calling | ||
| 4661 | +C<POSIX::open>. | ||
| 4662 | + | ||
| 4663 | +Returns C<undef> on failure. | ||
| 4664 | + | ||
| 4665 | +=item errno | ||
| 4666 | + | ||
| 4667 | +Returns the value of errno. | ||
| 4668 | + | ||
| 4669 | + $errno = POSIX::errno(); | ||
| 4670 | + | ||
| 4671 | +This identical to the numerical values of the C<$!>, see L<perlvar/$ERRNO>. | ||
| 4672 | + | ||
| 4673 | +=item execl | ||
| 4674 | + | ||
| 4675 | +execl() is C-specific, see L<perlfunc/exec>. | ||
| 4676 | + | ||
| 4677 | +=item execle | ||
| 4678 | + | ||
| 4679 | +execle() is C-specific, see L<perlfunc/exec>. | ||
| 4680 | + | ||
| 4681 | +=item execlp | ||
| 4682 | + | ||
| 4683 | +execlp() is C-specific, see L<perlfunc/exec>. | ||
| 4684 | + | ||
| 4685 | +=item execv | ||
| 4686 | + | ||
| 4687 | +execv() is C-specific, see L<perlfunc/exec>. | ||
| 4688 | + | ||
| 4689 | +=item execve | ||
| 4690 | + | ||
| 4691 | +execve() is C-specific, see L<perlfunc/exec>. | ||
| 4692 | + | ||
| 4693 | +=item execvp | ||
| 4694 | + | ||
| 4695 | +execvp() is C-specific, see L<perlfunc/exec>. | ||
| 4696 | + | ||
| 4697 | +=item exit | ||
| 4698 | + | ||
| 4699 | +This is identical to Perl's builtin C<exit()> function for exiting the | ||
| 4700 | +program, see L<perlfunc/exit>. | ||
| 4701 | + | ||
| 4702 | +=item exp | ||
| 4703 | + | ||
| 4704 | +This is identical to Perl's builtin C<exp()> function for | ||
| 4705 | +returning the exponent (I<e>-based) of the numerical argument, | ||
| 4706 | +see L<perlfunc/exp>. | ||
| 4707 | + | ||
| 4708 | +=item fabs | ||
| 4709 | + | ||
| 4710 | +This is identical to Perl's builtin C<abs()> function for returning | ||
| 4711 | +the absolute value of the numerical argument, see L<perlfunc/abs>. | ||
| 4712 | + | ||
| 4713 | +=item fclose | ||
| 4714 | + | ||
| 4715 | +Use method C<IO::Handle::close()> instead, or see L<perlfunc/close>. | ||
| 4716 | + | ||
| 4717 | +=item fcntl | ||
| 4718 | + | ||
| 4719 | +This is identical to Perl's builtin C<fcntl()> function, | ||
| 4720 | +see L<perlfunc/fcntl>. | ||
| 4721 | + | ||
| 4722 | +=item fdopen | ||
| 4723 | + | ||
| 4724 | +Use method C<IO::Handle::new_from_fd()> instead, or see L<perlfunc/open>. | ||
| 4725 | + | ||
| 4726 | +=item feof | ||
| 4727 | + | ||
| 4728 | +Use method C<IO::Handle::eof()> instead, or see L<perlfunc/eof>. | ||
| 4729 | + | ||
| 4730 | +=item ferror | ||
| 4731 | + | ||
| 4732 | +Use method C<IO::Handle::error()> instead. | ||
| 4733 | + | ||
| 4734 | +=item fflush | ||
| 4735 | + | ||
| 4736 | +Use method C<IO::Handle::flush()> instead. | ||
| 4737 | +See also L<perlvar/$OUTPUT_AUTOFLUSH>. | ||
| 4738 | + | ||
| 4739 | +=item fgetc | ||
| 4740 | + | ||
| 4741 | +Use method C<IO::Handle::getc()> instead, or see L<perlfunc/read>. | ||
| 4742 | + | ||
| 4743 | +=item fgetpos | ||
| 4744 | + | ||
| 4745 | +Use method C<IO::Seekable::getpos()> instead, or see L<L/seek>. | ||
| 4746 | + | ||
| 4747 | +=item fgets | ||
| 4748 | + | ||
| 4749 | +Use method C<IO::Handle::gets()> instead. Similar to E<lt>E<gt>, also known | ||
| 4750 | +as L<perlfunc/readline>. | ||
| 4751 | + | ||
| 4752 | +=item fileno | ||
| 4753 | + | ||
| 4754 | +Use method C<IO::Handle::fileno()> instead, or see L<perlfunc/fileno>. | ||
| 4755 | + | ||
| 4756 | +=item floor | ||
| 4757 | + | ||
| 4758 | +This is identical to the C function C<floor()>, returning the largest | ||
| 4759 | +integer value less than or equal to the numerical argument. | ||
| 4760 | + | ||
| 4761 | +=item fmod | ||
| 4762 | + | ||
| 4763 | +This is identical to the C function C<fmod()>. | ||
| 4764 | + | ||
| 4765 | + $r = fmod($x, $y); | ||
| 4766 | + | ||
| 4767 | +It returns the remainder C<$r = $x - $n*$y>, where C<$n = trunc($x/$y)>. | ||
| 4768 | +The C<$r> has the same sign as C<$x> and magnitude (absolute value) | ||
| 4769 | +less than the magnitude of C<$y>. | ||
| 4770 | + | ||
| 4771 | +=item fopen | ||
| 4772 | + | ||
| 4773 | +Use method C<IO::File::open()> instead, or see L<perlfunc/open>. | ||
| 4774 | + | ||
| 4775 | +=item fork | ||
| 4776 | + | ||
| 4777 | +This is identical to Perl's builtin C<fork()> function | ||
| 4778 | +for duplicating the current process, see L<perlfunc/fork> | ||
| 4779 | +and L<perlfork> if you are in Windows. | ||
| 4780 | + | ||
| 4781 | +=item fpathconf | ||
| 4782 | + | ||
| 4783 | +Retrieves the value of a configurable limit on a file or directory. This | ||
| 4784 | +uses file descriptors such as those obtained by calling C<POSIX::open>. | ||
| 4785 | + | ||
| 4786 | +The following will determine the maximum length of the longest allowable | ||
| 4787 | +pathname on the filesystem which holds C</var/foo>. | ||
| 4788 | + | ||
| 4789 | + $fd = POSIX::open( "/var/foo", &POSIX::O_RDONLY ); | ||
| 4790 | + $path_max = POSIX::fpathconf( $fd, &POSIX::_PC_PATH_MAX ); | ||
| 4791 | + | ||
| 4792 | +Returns C<undef> on failure. | ||
| 4793 | + | ||
| 4794 | +=item fprintf | ||
| 4795 | + | ||
| 4796 | +fprintf() is C-specific, see L<perlfunc/printf> instead. | ||
| 4797 | + | ||
| 4798 | +=item fputc | ||
| 4799 | + | ||
| 4800 | +fputc() is C-specific, see L<perlfunc/print> instead. | ||
| 4801 | + | ||
| 4802 | +=item fputs | ||
| 4803 | + | ||
| 4804 | +fputs() is C-specific, see L<perlfunc/print> instead. | ||
| 4805 | + | ||
| 4806 | +=item fread | ||
| 4807 | + | ||
| 4808 | +fread() is C-specific, see L<perlfunc/read> instead. | ||
| 4809 | + | ||
| 4810 | +=item free | ||
| 4811 | + | ||
| 4812 | +free() is C-specific. Perl does memory management transparently. | ||
| 4813 | + | ||
| 4814 | +=item freopen | ||
| 4815 | + | ||
| 4816 | +freopen() is C-specific, see L<perlfunc/open> instead. | ||
| 4817 | + | ||
| 4818 | +=item frexp | ||
| 4819 | + | ||
| 4820 | +Return the mantissa and exponent of a floating-point number. | ||
| 4821 | + | ||
| 4822 | + ($mantissa, $exponent) = POSIX::frexp( 1.234e56 ); | ||
| 4823 | + | ||
| 4824 | +=item fscanf | ||
| 4825 | + | ||
| 4826 | +fscanf() is C-specific, use E<lt>E<gt> and regular expressions instead. | ||
| 4827 | + | ||
| 4828 | +=item fseek | ||
| 4829 | + | ||
| 4830 | +Use method C<IO::Seekable::seek()> instead, or see L<perlfunc/seek>. | ||
| 4831 | + | ||
| 4832 | +=item fsetpos | ||
| 4833 | + | ||
| 4834 | +Use method C<IO::Seekable::setpos()> instead, or seek L<perlfunc/seek>. | ||
| 4835 | + | ||
| 4836 | +=item fstat | ||
| 4837 | + | ||
| 4838 | +Get file status. This uses file descriptors such as those obtained by | ||
| 4839 | +calling C<POSIX::open>. The data returned is identical to the data from | ||
| 4840 | +Perl's builtin C<stat> function. | ||
| 4841 | + | ||
| 4842 | + $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); | ||
| 4843 | + @stats = POSIX::fstat( $fd ); | ||
| 4844 | + | ||
| 4845 | +=item fsync | ||
| 4846 | + | ||
| 4847 | +Use method C<IO::Handle::sync()> instead. | ||
| 4848 | + | ||
| 4849 | +=item ftell | ||
| 4850 | + | ||
| 4851 | +Use method C<IO::Seekable::tell()> instead, or see L<perlfunc/tell>. | ||
| 4852 | + | ||
| 4853 | +=item fwrite | ||
| 4854 | + | ||
| 4855 | +fwrite() is C-specific, see L<perlfunc/print> instead. | ||
| 4856 | + | ||
| 4857 | +=item getc | ||
| 4858 | + | ||
| 4859 | +This is identical to Perl's builtin C<getc()> function, | ||
| 4860 | +see L<perlfunc/getc>. | ||
| 4861 | + | ||
| 4862 | +=item getchar | ||
| 4863 | + | ||
| 4864 | +Returns one character from STDIN. Identical to Perl's C<getc()>, | ||
| 4865 | +see L<perlfunc/getc>. | ||
| 4866 | + | ||
| 4867 | +=item getcwd | ||
| 4868 | + | ||
| 4869 | +Returns the name of the current working directory. | ||
| 4870 | +See also L<Cwd>. | ||
| 4871 | + | ||
| 4872 | +=item getegid | ||
| 4873 | + | ||
| 4874 | +Returns the effective group identifier. Similar to Perl' s builtin | ||
| 4875 | +variable C<$(>, see L<perlvar/$EGID>. | ||
| 4876 | + | ||
| 4877 | +=item getenv | ||
| 4878 | + | ||
| 4879 | +Returns the value of the specified environment variable. | ||
| 4880 | +The same information is available through the C<%ENV> array. | ||
| 4881 | + | ||
| 4882 | +=item geteuid | ||
| 4883 | + | ||
| 4884 | +Returns the effective user identifier. Identical to Perl's builtin C<$E<gt>> | ||
| 4885 | +variable, see L<perlvar/$EUID>. | ||
| 4886 | + | ||
| 4887 | +=item getgid | ||
| 4888 | + | ||
| 4889 | +Returns the user's real group identifier. Similar to Perl's builtin | ||
| 4890 | +variable C<$)>, see L<perlvar/$GID>. | ||
| 4891 | + | ||
| 4892 | +=item getgrgid | ||
| 4893 | + | ||
| 4894 | +This is identical to Perl's builtin C<getgrgid()> function for | ||
| 4895 | +returning group entries by group identifiers, see | ||
| 4896 | +L<perlfunc/getgrgid>. | ||
| 4897 | + | ||
| 4898 | +=item getgrnam | ||
| 4899 | + | ||
| 4900 | +This is identical to Perl's builtin C<getgrnam()> function for | ||
| 4901 | +returning group entries by group names, see L<perlfunc/getgrnam>. | ||
| 4902 | + | ||
| 4903 | +=item getgroups | ||
| 4904 | + | ||
| 4905 | +Returns the ids of the user's supplementary groups. Similar to Perl's | ||
| 4906 | +builtin variable C<$)>, see L<perlvar/$GID>. | ||
| 4907 | + | ||
| 4908 | +=item getlogin | ||
| 4909 | + | ||
| 4910 | +This is identical to Perl's builtin C<getlogin()> function for | ||
| 4911 | +returning the user name associated with the current session, see | ||
| 4912 | +L<perlfunc/getlogin>. | ||
| 4913 | + | ||
| 4914 | +=item getpgrp | ||
| 4915 | + | ||
| 4916 | +This is identical to Perl's builtin C<getpgrp()> function for | ||
| 4917 | +returning the process group identifier of the current process, see | ||
| 4918 | +L<perlfunc/getpgrp>. | ||
| 4919 | + | ||
| 4920 | +=item getpid | ||
| 4921 | + | ||
| 4922 | +Returns the process identifier. Identical to Perl's builtin | ||
| 4923 | +variable C<$$>, see L<perlvar/$PID>. | ||
| 4924 | + | ||
| 4925 | +=item getppid | ||
| 4926 | + | ||
| 4927 | +This is identical to Perl's builtin C<getppid()> function for | ||
| 4928 | +returning the process identifier of the parent process of the current | ||
| 4929 | +process , see L<perlfunc/getppid>. | ||
| 4930 | + | ||
| 4931 | +=item getpwnam | ||
| 4932 | + | ||
| 4933 | +This is identical to Perl's builtin C<getpwnam()> function for | ||
| 4934 | +returning user entries by user names, see L<perlfunc/getpwnam>. | ||
| 4935 | + | ||
| 4936 | +=item getpwuid | ||
| 4937 | + | ||
| 4938 | +This is identical to Perl's builtin C<getpwuid()> function for | ||
| 4939 | +returning user entries by user identifiers, see L<perlfunc/getpwuid>. | ||
| 4940 | + | ||
| 4941 | +=item gets | ||
| 4942 | + | ||
| 4943 | +Returns one line from C<STDIN>, similar to E<lt>E<gt>, also known | ||
| 4944 | +as the C<readline()> function, see L<perlfunc/readline>. | ||
| 4945 | + | ||
| 4946 | +B<NOTE>: if you have C programs that still use C<gets()>, be very | ||
| 4947 | +afraid. The C<gets()> function is a source of endless grief because | ||
| 4948 | +it has no buffer overrun checks. It should B<never> be used. The | ||
| 4949 | +C<fgets()> function should be preferred instead. | ||
| 4950 | + | ||
| 4951 | +=item getuid | ||
| 4952 | + | ||
| 4953 | +Returns the user's identifier. Identical to Perl's builtin C<$E<lt>> variable, | ||
| 4954 | +see L<perlvar/$UID>. | ||
| 4955 | + | ||
| 4956 | +=item gmtime | ||
| 4957 | + | ||
| 4958 | +This is identical to Perl's builtin C<gmtime()> function for | ||
| 4959 | +converting seconds since the epoch to a date in Greenwich Mean Time, | ||
| 4960 | +see L<perlfunc/gmtime>. | ||
| 4961 | + | ||
| 4962 | +=item isalnum | ||
| 4963 | + | ||
| 4964 | +This is identical to the C function, except that it can apply to a | ||
| 4965 | +single character or to a whole string. Note that locale settings may | ||
| 4966 | +affect what characters are considered C<isalnum>. Does not work on | ||
| 4967 | +Unicode characters code point 256 or higher. Consider using regular | ||
| 4968 | +expressions and the C</[[:alnum:]]/> construct instead, or possibly | ||
| 4969 | +the C</\w/> construct. | ||
| 4970 | + | ||
| 4971 | +=item isalpha | ||
| 4972 | + | ||
| 4973 | +This is identical to the C function, except that it can apply to | ||
| 4974 | +a single character or to a whole string. Note that locale settings | ||
| 4975 | +may affect what characters are considered C<isalpha>. Does not work | ||
| 4976 | +on Unicode characters code point 256 or higher. Consider using regular | ||
| 4977 | +expressions and the C</[[:alpha:]]/> construct instead. | ||
| 4978 | + | ||
| 4979 | +=item isatty | ||
| 4980 | + | ||
| 4981 | +Returns a boolean indicating whether the specified filehandle is connected | ||
| 4982 | +to a tty. Similar to the C<-t> operator, see L<perlfunc/-X>. | ||
| 4983 | + | ||
| 4984 | +=item iscntrl | ||
| 4985 | + | ||
| 4986 | +This is identical to the C function, except that it can apply to | ||
| 4987 | +a single character or to a whole string. Note that locale settings | ||
| 4988 | +may affect what characters are considered C<iscntrl>. Does not work | ||
| 4989 | +on Unicode characters code point 256 or higher. Consider using regular | ||
| 4990 | +expressions and the C</[[:cntrl:]]/> construct instead. | ||
| 4991 | + | ||
| 4992 | +=item isdigit | ||
| 4993 | + | ||
| 4994 | +This is identical to the C function, except that it can apply to | ||
| 4995 | +a single character or to a whole string. Note that locale settings | ||
| 4996 | +may affect what characters are considered C<isdigit> (unlikely, but | ||
| 4997 | +still possible). Does not work on Unicode characters code point 256 | ||
| 4998 | +or higher. Consider using regular expressions and the C</[[:digit:]]/> | ||
| 4999 | +construct instead, or the C</\d/> construct. | ||
| 5000 | + | ||
| 5001 | +=item isgraph | ||
| 5002 | + | ||
| 5003 | +This is identical to the C function, except that it can apply to | ||
| 5004 | +a single character or to a whole string. Note that locale settings | ||
| 5005 | +may affect what characters are considered C<isgraph>. Does not work | ||
| 5006 | +on Unicode characters code point 256 or higher. Consider using regular | ||
| 5007 | +expressions and the C</[[:graph:]]/> construct instead. | ||
| 5008 | + | ||
| 5009 | +=item islower | ||
| 5010 | + | ||
| 5011 | +This is identical to the C function, except that it can apply to | ||
| 5012 | +a single character or to a whole string. Note that locale settings | ||
| 5013 | +may affect what characters are considered C<islower>. Does not work | ||
| 5014 | +on Unicode characters code point 256 or higher. Consider using regular | ||
| 5015 | +expressions and the C</[[:lower:]]/> construct instead. Do B<not> use | ||
| 5016 | +C</[a-z]/>. | ||
| 5017 | + | ||
| 5018 | +=item isprint | ||
| 5019 | + | ||
| 5020 | +This is identical to the C function, except that it can apply to | ||
| 5021 | +a single character or to a whole string. Note that locale settings | ||
| 5022 | +may affect what characters are considered C<isprint>. Does not work | ||
| 5023 | +on Unicode characters code point 256 or higher. Consider using regular | ||
| 5024 | +expressions and the C</[[:print:]]/> construct instead. | ||
| 5025 | + | ||
| 5026 | +=item ispunct | ||
| 5027 | + | ||
| 5028 | +This is identical to the C function, except that it can apply to | ||
| 5029 | +a single character or to a whole string. Note that locale settings | ||
| 5030 | +may affect what characters are considered C<ispunct>. Does not work | ||
| 5031 | +on Unicode characters code point 256 or higher. Consider using regular | ||
| 5032 | +expressions and the C</[[:punct:]]/> construct instead. | ||
| 5033 | + | ||
| 5034 | +=item isspace | ||
| 5035 | + | ||
| 5036 | +This is identical to the C function, except that it can apply to | ||
| 5037 | +a single character or to a whole string. Note that locale settings | ||
| 5038 | +may affect what characters are considered C<isspace>. Does not work | ||
| 5039 | +on Unicode characters code point 256 or higher. Consider using regular | ||
| 5040 | +expressions and the C</[[:space:]]/> construct instead, or the C</\s/> | ||
| 5041 | +construct. (Note that C</\s/> and C</[[:space:]]/> are slightly | ||
| 5042 | +different in that C</[[:space:]]/> can normally match a vertical tab, | ||
| 5043 | +while C</\s/> does not.) | ||
| 5044 | + | ||
| 5045 | +=item isupper | ||
| 5046 | + | ||
| 5047 | +This is identical to the C function, except that it can apply to | ||
| 5048 | +a single character or to a whole string. Note that locale settings | ||
| 5049 | +may affect what characters are considered C<isupper>. Does not work | ||
| 5050 | +on Unicode characters code point 256 or higher. Consider using regular | ||
| 5051 | +expressions and the C</[[:upper:]]/> construct instead. Do B<not> use | ||
| 5052 | +C</[A-Z]/>. | ||
| 5053 | + | ||
| 5054 | +=item isxdigit | ||
| 5055 | + | ||
| 5056 | +This is identical to the C function, except that it can apply to a single | ||
| 5057 | +character or to a whole string. Note that locale settings may affect what | ||
| 5058 | +characters are considered C<isxdigit> (unlikely, but still possible). | ||
| 5059 | +Does not work on Unicode characters code point 256 or higher. | ||
| 5060 | +Consider using regular expressions and the C</[[:xdigit:]]/> | ||
| 5061 | +construct instead, or simply C</[0-9a-f]/i>. | ||
| 5062 | + | ||
| 5063 | +=item kill | ||
| 5064 | + | ||
| 5065 | +This is identical to Perl's builtin C<kill()> function for sending | ||
| 5066 | +signals to processes (often to terminate them), see L<perlfunc/kill>. | ||
| 5067 | + | ||
| 5068 | +=item labs | ||
| 5069 | + | ||
| 5070 | +(For returning absolute values of long integers.) | ||
| 5071 | +labs() is C-specific, see L<perlfunc/abs> instead. | ||
| 5072 | + | ||
| 5073 | +=item lchown | ||
| 5074 | + | ||
| 5075 | +This is identical to the C function, except the order of arguments is | ||
| 5076 | +consistent with Perl's builtin C<chown()> with the added restriction | ||
| 5077 | +of only one path, not an list of paths. Does the same thing as the | ||
| 5078 | +C<chown()> function but changes the owner of a symbolic link instead | ||
| 5079 | +of the file the symbolic link points to. | ||
| 5080 | + | ||
| 5081 | +=item ldexp | ||
| 5082 | + | ||
| 5083 | +This is identical to the C function C<ldexp()> | ||
| 5084 | +for multiplying floating point numbers with powers of two. | ||
| 5085 | + | ||
| 5086 | + $x_quadrupled = POSIX::ldexp($x, 2); | ||
| 5087 | + | ||
| 5088 | +=item ldiv | ||
| 5089 | + | ||
| 5090 | +(For computing dividends of long integers.) | ||
| 5091 | +ldiv() is C-specific, use C</> and C<int()> instead. | ||
| 5092 | + | ||
| 5093 | +=item link | ||
| 5094 | + | ||
| 5095 | +This is identical to Perl's builtin C<link()> function | ||
| 5096 | +for creating hard links into files, see L<perlfunc/link>. | ||
| 5097 | + | ||
| 5098 | +=item localeconv | ||
| 5099 | + | ||
| 5100 | +Get numeric formatting information. Returns a reference to a hash | ||
| 5101 | +containing the current locale formatting values. | ||
| 5102 | + | ||
| 5103 | +Here is how to query the database for the B<de> (Deutsch or German) locale. | ||
| 5104 | + | ||
| 5105 | + $loc = POSIX::setlocale( &POSIX::LC_ALL, "de" ); | ||
| 5106 | + print "Locale = $loc\n"; | ||
| 5107 | + $lconv = POSIX::localeconv(); | ||
| 5108 | + print "decimal_point = ", $lconv->{decimal_point}, "\n"; | ||
| 5109 | + print "thousands_sep = ", $lconv->{thousands_sep}, "\n"; | ||
| 5110 | + print "grouping = ", $lconv->{grouping}, "\n"; | ||
| 5111 | + print "int_curr_symbol = ", $lconv->{int_curr_symbol}, "\n"; | ||
| 5112 | + print "currency_symbol = ", $lconv->{currency_symbol}, "\n"; | ||
| 5113 | + print "mon_decimal_point = ", $lconv->{mon_decimal_point}, "\n"; | ||
| 5114 | + print "mon_thousands_sep = ", $lconv->{mon_thousands_sep}, "\n"; | ||
| 5115 | + print "mon_grouping = ", $lconv->{mon_grouping}, "\n"; | ||
| 5116 | + print "positive_sign = ", $lconv->{positive_sign}, "\n"; | ||
| 5117 | + print "negative_sign = ", $lconv->{negative_sign}, "\n"; | ||
| 5118 | + print "int_frac_digits = ", $lconv->{int_frac_digits}, "\n"; | ||
| 5119 | + print "frac_digits = ", $lconv->{frac_digits}, "\n"; | ||
| 5120 | + print "p_cs_precedes = ", $lconv->{p_cs_precedes}, "\n"; | ||
| 5121 | + print "p_sep_by_space = ", $lconv->{p_sep_by_space}, "\n"; | ||
| 5122 | + print "n_cs_precedes = ", $lconv->{n_cs_precedes}, "\n"; | ||
| 5123 | + print "n_sep_by_space = ", $lconv->{n_sep_by_space}, "\n"; | ||
| 5124 | + print "p_sign_posn = ", $lconv->{p_sign_posn}, "\n"; | ||
| 5125 | + print "n_sign_posn = ", $lconv->{n_sign_posn}, "\n"; | ||
| 5126 | + | ||
| 5127 | +=item localtime | ||
| 5128 | + | ||
| 5129 | +This is identical to Perl's builtin C<localtime()> function for | ||
| 5130 | +converting seconds since the epoch to a date see L<perlfunc/localtime>. | ||
| 5131 | + | ||
| 5132 | +=item log | ||
| 5133 | + | ||
| 5134 | +This is identical to Perl's builtin C<log()> function, | ||
| 5135 | +returning the natural (I<e>-based) logarithm of the numerical argument, | ||
| 5136 | +see L<perlfunc/log>. | ||
| 5137 | + | ||
| 5138 | +=item log10 | ||
| 5139 | + | ||
| 5140 | +This is identical to the C function C<log10()>, | ||
| 5141 | +returning the 10-base logarithm of the numerical argument. | ||
| 5142 | +You can also use | ||
| 5143 | + | ||
| 5144 | + sub log10 { log($_[0]) / log(10) } | ||
| 5145 | + | ||
| 5146 | +or | ||
| 5147 | + | ||
| 5148 | + sub log10 { log($_[0]) / 2.30258509299405 } | ||
| 5149 | + | ||
| 5150 | +or | ||
| 5151 | + | ||
| 5152 | + sub log10 { log($_[0]) * 0.434294481903252 } | ||
| 5153 | + | ||
| 5154 | +=item longjmp | ||
| 5155 | + | ||
| 5156 | +longjmp() is C-specific: use L<perlfunc/die> instead. | ||
| 5157 | + | ||
| 5158 | +=item lseek | ||
| 5159 | + | ||
| 5160 | +Move the file's read/write position. This uses file descriptors such as | ||
| 5161 | +those obtained by calling C<POSIX::open>. | ||
| 5162 | + | ||
| 5163 | + $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); | ||
| 5164 | + $off_t = POSIX::lseek( $fd, 0, &POSIX::SEEK_SET ); | ||
| 5165 | + | ||
| 5166 | +Returns C<undef> on failure. | ||
| 5167 | + | ||
| 5168 | +=item malloc | ||
| 5169 | + | ||
| 5170 | +malloc() is C-specific. Perl does memory management transparently. | ||
| 5171 | + | ||
| 5172 | +=item mblen | ||
| 5173 | + | ||
| 5174 | +This is identical to the C function C<mblen()>. | ||
| 5175 | +Perl does not have any support for the wide and multibyte | ||
| 5176 | +characters of the C standards, so this might be a rather | ||
| 5177 | +useless function. | ||
| 5178 | + | ||
| 5179 | +=item mbstowcs | ||
| 5180 | + | ||
| 5181 | +This is identical to the C function C<mbstowcs()>. | ||
| 5182 | +Perl does not have any support for the wide and multibyte | ||
| 5183 | +characters of the C standards, so this might be a rather | ||
| 5184 | +useless function. | ||
| 5185 | + | ||
| 5186 | +=item mbtowc | ||
| 5187 | + | ||
| 5188 | +This is identical to the C function C<mbtowc()>. | ||
| 5189 | +Perl does not have any support for the wide and multibyte | ||
| 5190 | +characters of the C standards, so this might be a rather | ||
| 5191 | +useless function. | ||
| 5192 | + | ||
| 5193 | +=item memchr | ||
| 5194 | + | ||
| 5195 | +memchr() is C-specific, see L<perlfunc/index> instead. | ||
| 5196 | + | ||
| 5197 | +=item memcmp | ||
| 5198 | + | ||
| 5199 | +memcmp() is C-specific, use C<eq> instead, see L<perlop>. | ||
| 5200 | + | ||
| 5201 | +=item memcpy | ||
| 5202 | + | ||
| 5203 | +memcpy() is C-specific, use C<=>, see L<perlop>, or see L<perlfunc/substr>. | ||
| 5204 | + | ||
| 5205 | +=item memmove | ||
| 5206 | + | ||
| 5207 | +memmove() is C-specific, use C<=>, see L<perlop>, or see L<perlfunc/substr>. | ||
| 5208 | + | ||
| 5209 | +=item memset | ||
| 5210 | + | ||
| 5211 | +memset() is C-specific, use C<x> instead, see L<perlop>. | ||
| 5212 | + | ||
| 5213 | +=item mkdir | ||
| 5214 | + | ||
| 5215 | +This is identical to Perl's builtin C<mkdir()> function | ||
| 5216 | +for creating directories, see L<perlfunc/mkdir>. | ||
| 5217 | + | ||
| 5218 | +=item mkfifo | ||
| 5219 | + | ||
| 5220 | +This is similar to the C function C<mkfifo()> for creating | ||
| 5221 | +FIFO special files. | ||
| 5222 | + | ||
| 5223 | + if (mkfifo($path, $mode)) { .... | ||
| 5224 | + | ||
| 5225 | +Returns C<undef> on failure. The C<$mode> is similar to the | ||
| 5226 | +mode of C<mkdir()>, see L<perlfunc/mkdir>, though for C<mkfifo> | ||
| 5227 | +you B<must> specify the C<$mode>. | ||
| 5228 | + | ||
| 5229 | +=item mktime | ||
| 5230 | + | ||
| 5231 | +Convert date/time info to a calendar time. | ||
| 5232 | + | ||
| 5233 | +Synopsis: | ||
| 5234 | + | ||
| 5235 | + mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = -1) | ||
| 5236 | + | ||
| 5237 | +The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero. | ||
| 5238 | +I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The | ||
| 5239 | +year (C<year>) is given in years since 1900. I.e. The year 1995 is 95; the | ||
| 5240 | +year 2001 is 101. Consult your system's C<mktime()> manpage for details | ||
| 5241 | +about these and the other arguments. | ||
| 5242 | + | ||
| 5243 | +Calendar time for December 12, 1995, at 10:30 am. | ||
| 5244 | + | ||
| 5245 | + $time_t = POSIX::mktime( 0, 30, 10, 12, 11, 95 ); | ||
| 5246 | + print "Date = ", POSIX::ctime($time_t); | ||
| 5247 | + | ||
| 5248 | +Returns C<undef> on failure. | ||
| 5249 | + | ||
| 5250 | +=item modf | ||
| 5251 | + | ||
| 5252 | +Return the integral and fractional parts of a floating-point number. | ||
| 5253 | + | ||
| 5254 | + ($fractional, $integral) = POSIX::modf( 3.14 ); | ||
| 5255 | + | ||
| 5256 | +=item nice | ||
| 5257 | + | ||
| 5258 | +This is similar to the C function C<nice()>, for changing | ||
| 5259 | +the scheduling preference of the current process. Positive | ||
| 5260 | +arguments mean more polite process, negative values more | ||
| 5261 | +needy process. Normal user processes can only be more polite. | ||
| 5262 | + | ||
| 5263 | +Returns C<undef> on failure. | ||
| 5264 | + | ||
| 5265 | +=item offsetof | ||
| 5266 | + | ||
| 5267 | +offsetof() is C-specific, you probably want to see L<perlfunc/pack> instead. | ||
| 5268 | + | ||
| 5269 | +=item open | ||
| 5270 | + | ||
| 5271 | +Open a file for reading for writing. This returns file descriptors, not | ||
| 5272 | +Perl filehandles. Use C<POSIX::close> to close the file. | ||
| 5273 | + | ||
| 5274 | +Open a file read-only with mode 0666. | ||
| 5275 | + | ||
| 5276 | + $fd = POSIX::open( "foo" ); | ||
| 5277 | + | ||
| 5278 | +Open a file for read and write. | ||
| 5279 | + | ||
| 5280 | + $fd = POSIX::open( "foo", &POSIX::O_RDWR ); | ||
| 5281 | + | ||
| 5282 | +Open a file for write, with truncation. | ||
| 5283 | + | ||
| 5284 | + $fd = POSIX::open( "foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC ); | ||
| 5285 | + | ||
| 5286 | +Create a new file with mode 0640. Set up the file for writing. | ||
| 5287 | + | ||
| 5288 | + $fd = POSIX::open( "foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0640 ); | ||
| 5289 | + | ||
| 5290 | +Returns C<undef> on failure. | ||
| 5291 | + | ||
| 5292 | +See also L<perlfunc/sysopen>. | ||
| 5293 | + | ||
| 5294 | +=item opendir | ||
| 5295 | + | ||
| 5296 | +Open a directory for reading. | ||
| 5297 | + | ||
| 5298 | + $dir = POSIX::opendir( "/var" ); | ||
| 5299 | + @files = POSIX::readdir( $dir ); | ||
| 5300 | + POSIX::closedir( $dir ); | ||
| 5301 | + | ||
| 5302 | +Returns C<undef> on failure. | ||
| 5303 | + | ||
| 5304 | +=item pathconf | ||
| 5305 | + | ||
| 5306 | +Retrieves the value of a configurable limit on a file or directory. | ||
| 5307 | + | ||
| 5308 | +The following will determine the maximum length of the longest allowable | ||
| 5309 | +pathname on the filesystem which holds C</var>. | ||
| 5310 | + | ||
| 5311 | + $path_max = POSIX::pathconf( "/var", &POSIX::_PC_PATH_MAX ); | ||
| 5312 | + | ||
| 5313 | +Returns C<undef> on failure. | ||
| 5314 | + | ||
| 5315 | +=item pause | ||
| 5316 | + | ||
| 5317 | +This is similar to the C function C<pause()>, which suspends | ||
| 5318 | +the execution of the current process until a signal is received. | ||
| 5319 | + | ||
| 5320 | +Returns C<undef> on failure. | ||
| 5321 | + | ||
| 5322 | +=item perror | ||
| 5323 | + | ||
| 5324 | +This is identical to the C function C<perror()>, which outputs to the | ||
| 5325 | +standard error stream the specified message followed by ": " and the | ||
| 5326 | +current error string. Use the C<warn()> function and the C<$!> | ||
| 5327 | +variable instead, see L<perlfunc/warn> and L<perlvar/$ERRNO>. | ||
| 5328 | + | ||
| 5329 | +=item pipe | ||
| 5330 | + | ||
| 5331 | +Create an interprocess channel. This returns file descriptors like those | ||
| 5332 | +returned by C<POSIX::open>. | ||
| 5333 | + | ||
| 5334 | + my ($read, $write) = POSIX::pipe(); | ||
| 5335 | + POSIX::write( $write, "hello", 5 ); | ||
| 5336 | + POSIX::read( $read, $buf, 5 ); | ||
| 5337 | + | ||
| 5338 | +See also L<perlfunc/pipe>. | ||
| 5339 | + | ||
| 5340 | +=item pow | ||
| 5341 | + | ||
| 5342 | +Computes C<$x> raised to the power C<$exponent>. | ||
| 5343 | + | ||
| 5344 | + $ret = POSIX::pow( $x, $exponent ); | ||
| 5345 | + | ||
| 5346 | +You can also use the C<**> operator, see L<perlop>. | ||
| 5347 | + | ||
| 5348 | +=item printf | ||
| 5349 | + | ||
| 5350 | +Formats and prints the specified arguments to STDOUT. | ||
| 5351 | +See also L<perlfunc/printf>. | ||
| 5352 | + | ||
| 5353 | +=item putc | ||
| 5354 | + | ||
| 5355 | +putc() is C-specific, see L<perlfunc/print> instead. | ||
| 5356 | + | ||
| 5357 | +=item putchar | ||
| 5358 | + | ||
| 5359 | +putchar() is C-specific, see L<perlfunc/print> instead. | ||
| 5360 | + | ||
| 5361 | +=item puts | ||
| 5362 | + | ||
| 5363 | +puts() is C-specific, see L<perlfunc/print> instead. | ||
| 5364 | + | ||
| 5365 | +=item qsort | ||
| 5366 | + | ||
| 5367 | +qsort() is C-specific, see L<perlfunc/sort> instead. | ||
| 5368 | + | ||
| 5369 | +=item raise | ||
| 5370 | + | ||
| 5371 | +Sends the specified signal to the current process. | ||
| 5372 | +See also L<perlfunc/kill> and the C<$$> in L<perlvar/$PID>. | ||
| 5373 | + | ||
| 5374 | +=item rand | ||
| 5375 | + | ||
| 5376 | +C<rand()> is non-portable, see L<perlfunc/rand> instead. | ||
| 5377 | + | ||
| 5378 | +=item read | ||
| 5379 | + | ||
| 5380 | +Read from a file. This uses file descriptors such as those obtained by | ||
| 5381 | +calling C<POSIX::open>. If the buffer C<$buf> is not large enough for the | ||
| 5382 | +read then Perl will extend it to make room for the request. | ||
| 5383 | + | ||
| 5384 | + $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); | ||
| 5385 | + $bytes = POSIX::read( $fd, $buf, 3 ); | ||
| 5386 | + | ||
| 5387 | +Returns C<undef> on failure. | ||
| 5388 | + | ||
| 5389 | +See also L<perlfunc/sysread>. | ||
| 5390 | + | ||
| 5391 | +=item readdir | ||
| 5392 | + | ||
| 5393 | +This is identical to Perl's builtin C<readdir()> function | ||
| 5394 | +for reading directory entries, see L<perlfunc/readdir>. | ||
| 5395 | + | ||
| 5396 | +=item realloc | ||
| 5397 | + | ||
| 5398 | +realloc() is C-specific. Perl does memory management transparently. | ||
| 5399 | + | ||
| 5400 | +=item remove | ||
| 5401 | + | ||
| 5402 | +This is identical to Perl's builtin C<unlink()> function | ||
| 5403 | +for removing files, see L<perlfunc/unlink>. | ||
| 5404 | + | ||
| 5405 | +=item rename | ||
| 5406 | + | ||
| 5407 | +This is identical to Perl's builtin C<rename()> function | ||
| 5408 | +for renaming files, see L<perlfunc/rename>. | ||
| 5409 | + | ||
| 5410 | +=item rewind | ||
| 5411 | + | ||
| 5412 | +Seeks to the beginning of the file. | ||
| 5413 | + | ||
| 5414 | +=item rewinddir | ||
| 5415 | + | ||
| 5416 | +This is identical to Perl's builtin C<rewinddir()> function for | ||
| 5417 | +rewinding directory entry streams, see L<perlfunc/rewinddir>. | ||
| 5418 | + | ||
| 5419 | +=item rmdir | ||
| 5420 | + | ||
| 5421 | +This is identical to Perl's builtin C<rmdir()> function | ||
| 5422 | +for removing (empty) directories, see L<perlfunc/rmdir>. | ||
| 5423 | + | ||
| 5424 | +=item scanf | ||
| 5425 | + | ||
| 5426 | +scanf() is C-specific, use E<lt>E<gt> and regular expressions instead, | ||
| 5427 | +see L<perlre>. | ||
| 5428 | + | ||
| 5429 | +=item setgid | ||
| 5430 | + | ||
| 5431 | +Sets the real group identifier and the effective group identifier for | ||
| 5432 | +this process. Similar to assigning a value to the Perl's builtin | ||
| 5433 | +C<$)> variable, see L<perlvar/$EGID>, except that the latter | ||
| 5434 | +will change only the real user identifier, and that the setgid() | ||
| 5435 | +uses only a single numeric argument, as opposed to a space-separated | ||
| 5436 | +list of numbers. | ||
| 5437 | + | ||
| 5438 | +=item setjmp | ||
| 5439 | + | ||
| 5440 | +C<setjmp()> is C-specific: use C<eval {}> instead, | ||
| 5441 | +see L<perlfunc/eval>. | ||
| 5442 | + | ||
| 5443 | +=item setlocale | ||
| 5444 | + | ||
| 5445 | +Modifies and queries program's locale. The following examples assume | ||
| 5446 | + | ||
| 5447 | + use POSIX qw(setlocale LC_ALL LC_CTYPE); | ||
| 5448 | + | ||
| 5449 | +has been issued. | ||
| 5450 | + | ||
| 5451 | +The following will set the traditional UNIX system locale behavior | ||
| 5452 | +(the second argument C<"C">). | ||
| 5453 | + | ||
| 5454 | + $loc = setlocale( LC_ALL, "C" ); | ||
| 5455 | + | ||
| 5456 | +The following will query the current LC_CTYPE category. (No second | ||
| 5457 | +argument means 'query'.) | ||
| 5458 | + | ||
| 5459 | + $loc = setlocale( LC_CTYPE ); | ||
| 5460 | + | ||
| 5461 | +The following will set the LC_CTYPE behaviour according to the locale | ||
| 5462 | +environment variables (the second argument C<"">). | ||
| 5463 | +Please see your systems C<setlocale(3)> documentation for the locale | ||
| 5464 | +environment variables' meaning or consult L<perllocale>. | ||
| 5465 | + | ||
| 5466 | + $loc = setlocale( LC_CTYPE, "" ); | ||
| 5467 | + | ||
| 5468 | +The following will set the LC_COLLATE behaviour to Argentinian | ||
| 5469 | +Spanish. B<NOTE>: The naming and availability of locales depends on | ||
| 5470 | +your operating system. Please consult L<perllocale> for how to find | ||
| 5471 | +out which locales are available in your system. | ||
| 5472 | + | ||
| 5473 | + $loc = setlocale( LC_COLLATE, "es_AR.ISO8859-1" ); | ||
| 5474 | + | ||
| 5475 | +=item setpgid | ||
| 5476 | + | ||
| 5477 | +This is similar to the C function C<setpgid()> for | ||
| 5478 | +setting the process group identifier of the current process. | ||
| 5479 | + | ||
| 5480 | +Returns C<undef> on failure. | ||
| 5481 | + | ||
| 5482 | +=item setsid | ||
| 5483 | + | ||
| 5484 | +This is identical to the C function C<setsid()> for | ||
| 5485 | +setting the session identifier of the current process. | ||
| 5486 | + | ||
| 5487 | +=item setuid | ||
| 5488 | + | ||
| 5489 | +Sets the real user identifier and the effective user identifier for | ||
| 5490 | +this process. Similar to assigning a value to the Perl's builtin | ||
| 5491 | +C<$E<lt>> variable, see L<perlvar/$UID>, except that the latter | ||
| 5492 | +will change only the real user identifier. | ||
| 5493 | + | ||
| 5494 | +=item sigaction | ||
| 5495 | + | ||
| 5496 | +Detailed signal management. This uses C<POSIX::SigAction> objects for | ||
| 5497 | +the C<action> and C<oldaction> arguments (the oldaction can also be | ||
| 5498 | +just a hash reference). Consult your system's C<sigaction> manpage | ||
| 5499 | +for details, see also C<POSIX::SigRt>. | ||
| 5500 | + | ||
| 5501 | +Synopsis: | ||
| 5502 | + | ||
| 5503 | + sigaction(signal, action, oldaction = 0) | ||
| 5504 | + | ||
| 5505 | +Returns C<undef> on failure. The C<signal> must be a number (like | ||
| 5506 | +SIGHUP), not a string (like "SIGHUP"), though Perl does try hard | ||
| 5507 | +to understand you. | ||
| 5508 | + | ||
| 5509 | +If you use the SA_SIGINFO flag, the signal handler will in addition to | ||
| 5510 | +the first argument, the signal name, also receive a second argument, a | ||
| 5511 | +hash reference, inside which are the following keys with the following | ||
| 5512 | +semantics, as defined by POSIX/SUSv3: | ||
| 5513 | + | ||
| 5514 | + signo the signal number | ||
| 5515 | + errno the error number | ||
| 5516 | + code if this is zero or less, the signal was sent by | ||
| 5517 | + a user process and the uid and pid make sense, | ||
| 5518 | + otherwise the signal was sent by the kernel | ||
| 5519 | + | ||
| 5520 | +The following are also defined by POSIX/SUSv3, but unfortunately | ||
| 5521 | +not very widely implemented: | ||
| 5522 | + | ||
| 5523 | + pid the process id generating the signal | ||
| 5524 | + uid the uid of the process id generating the signal | ||
| 5525 | + status exit value or signal for SIGCHLD | ||
| 5526 | + band band event for SIGPOLL | ||
| 5527 | + | ||
| 5528 | +A third argument is also passed to the handler, which contains a copy | ||
| 5529 | +of the raw binary contents of the siginfo structure: if a system has | ||
| 5530 | +some non-POSIX fields, this third argument is where to unpack() them | ||
| 5531 | +from. | ||
| 5532 | + | ||
| 5533 | +Note that not all siginfo values make sense simultaneously (some are | ||
| 5534 | +valid only for certain signals, for example), and not all values make | ||
| 5535 | +sense from Perl perspective, you should to consult your system's | ||
| 5536 | +C<sigaction> and possibly also C<siginfo> documentation. | ||
| 5537 | + | ||
| 5538 | +=item siglongjmp | ||
| 5539 | + | ||
| 5540 | +siglongjmp() is C-specific: use L<perlfunc/die> instead. | ||
| 5541 | + | ||
| 5542 | +=item sigpending | ||
| 5543 | + | ||
| 5544 | +Examine signals that are blocked and pending. This uses C<POSIX::SigSet> | ||
| 5545 | +objects for the C<sigset> argument. Consult your system's C<sigpending> | ||
| 5546 | +manpage for details. | ||
| 5547 | + | ||
| 5548 | +Synopsis: | ||
| 5549 | + | ||
| 5550 | + sigpending(sigset) | ||
| 5551 | + | ||
| 5552 | +Returns C<undef> on failure. | ||
| 5553 | + | ||
| 5554 | +=item sigprocmask | ||
| 5555 | + | ||
| 5556 | +Change and/or examine calling process's signal mask. This uses | ||
| 5557 | +C<POSIX::SigSet> objects for the C<sigset> and C<oldsigset> arguments. | ||
| 5558 | +Consult your system's C<sigprocmask> manpage for details. | ||
| 5559 | + | ||
| 5560 | +Synopsis: | ||
| 5561 | + | ||
| 5562 | + sigprocmask(how, sigset, oldsigset = 0) | ||
| 5563 | + | ||
| 5564 | +Returns C<undef> on failure. | ||
| 5565 | + | ||
| 5566 | +=item sigsetjmp | ||
| 5567 | + | ||
| 5568 | +C<sigsetjmp()> is C-specific: use C<eval {}> instead, | ||
| 5569 | +see L<perlfunc/eval>. | ||
| 5570 | + | ||
| 5571 | +=item sigsuspend | ||
| 5572 | + | ||
| 5573 | +Install a signal mask and suspend process until signal arrives. This uses | ||
| 5574 | +C<POSIX::SigSet> objects for the C<signal_mask> argument. Consult your | ||
| 5575 | +system's C<sigsuspend> manpage for details. | ||
| 5576 | + | ||
| 5577 | +Synopsis: | ||
| 5578 | + | ||
| 5579 | + sigsuspend(signal_mask) | ||
| 5580 | + | ||
| 5581 | +Returns C<undef> on failure. | ||
| 5582 | + | ||
| 5583 | +=item sin | ||
| 5584 | + | ||
| 5585 | +This is identical to Perl's builtin C<sin()> function | ||
| 5586 | +for returning the sine of the numerical argument, | ||
| 5587 | +see L<perlfunc/sin>. See also L<Math::Trig>. | ||
| 5588 | + | ||
| 5589 | +=item sinh | ||
| 5590 | + | ||
| 5591 | +This is identical to the C function C<sinh()> | ||
| 5592 | +for returning the hyperbolic sine of the numerical argument. | ||
| 5593 | +See also L<Math::Trig>. | ||
| 5594 | + | ||
| 5595 | +=item sleep | ||
| 5596 | + | ||
| 5597 | +This is functionally identical to Perl's builtin C<sleep()> function | ||
| 5598 | +for suspending the execution of the current for process for certain | ||
| 5599 | +number of seconds, see L<perlfunc/sleep>. There is one significant | ||
| 5600 | +difference, however: C<POSIX::sleep()> returns the number of | ||
| 5601 | +B<unslept> seconds, while the C<CORE::sleep()> returns the | ||
| 5602 | +number of slept seconds. | ||
| 5603 | + | ||
| 5604 | +=item sprintf | ||
| 5605 | + | ||
| 5606 | +This is similar to Perl's builtin C<sprintf()> function | ||
| 5607 | +for returning a string that has the arguments formatted as requested, | ||
| 5608 | +see L<perlfunc/sprintf>. | ||
| 5609 | + | ||
| 5610 | +=item sqrt | ||
| 5611 | + | ||
| 5612 | +This is identical to Perl's builtin C<sqrt()> function. | ||
| 5613 | +for returning the square root of the numerical argument, | ||
| 5614 | +see L<perlfunc/sqrt>. | ||
| 5615 | + | ||
| 5616 | +=item srand | ||
| 5617 | + | ||
| 5618 | +Give a seed the pseudorandom number generator, see L<perlfunc/srand>. | ||
| 5619 | + | ||
| 5620 | +=item sscanf | ||
| 5621 | + | ||
| 5622 | +sscanf() is C-specific, use regular expressions instead, | ||
| 5623 | +see L<perlre>. | ||
| 5624 | + | ||
| 5625 | +=item stat | ||
| 5626 | + | ||
| 5627 | +This is identical to Perl's builtin C<stat()> function | ||
| 5628 | +for returning information about files and directories. | ||
| 5629 | + | ||
| 5630 | +=item strcat | ||
| 5631 | + | ||
| 5632 | +strcat() is C-specific, use C<.=> instead, see L<perlop>. | ||
| 5633 | + | ||
| 5634 | +=item strchr | ||
| 5635 | + | ||
| 5636 | +strchr() is C-specific, see L<perlfunc/index> instead. | ||
| 5637 | + | ||
| 5638 | +=item strcmp | ||
| 5639 | + | ||
| 5640 | +strcmp() is C-specific, use C<eq> or C<cmp> instead, see L<perlop>. | ||
| 5641 | + | ||
| 5642 | +=item strcoll | ||
| 5643 | + | ||
| 5644 | +This is identical to the C function C<strcoll()> | ||
| 5645 | +for collating (comparing) strings transformed using | ||
| 5646 | +the C<strxfrm()> function. Not really needed since | ||
| 5647 | +Perl can do this transparently, see L<perllocale>. | ||
| 5648 | + | ||
| 5649 | +=item strcpy | ||
| 5650 | + | ||
| 5651 | +strcpy() is C-specific, use C<=> instead, see L<perlop>. | ||
| 5652 | + | ||
| 5653 | +=item strcspn | ||
| 5654 | + | ||
| 5655 | +strcspn() is C-specific, use regular expressions instead, | ||
| 5656 | +see L<perlre>. | ||
| 5657 | + | ||
| 5658 | +=item strerror | ||
| 5659 | + | ||
| 5660 | +Returns the error string for the specified errno. | ||
| 5661 | +Identical to the string form of the C<$!>, see L<perlvar/$ERRNO>. | ||
| 5662 | + | ||
| 5663 | +=item strftime | ||
| 5664 | + | ||
| 5665 | +Convert date and time information to string. Returns the string. | ||
| 5666 | + | ||
| 5667 | +Synopsis: | ||
| 5668 | + | ||
| 5669 | + strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) | ||
| 5670 | + | ||
| 5671 | +The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero. | ||
| 5672 | +I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The | ||
| 5673 | +year (C<year>) is given in years since 1900. I.e., the year 1995 is 95; the | ||
| 5674 | +year 2001 is 101. Consult your system's C<strftime()> manpage for details | ||
| 5675 | +about these and the other arguments. | ||
| 5676 | + | ||
| 5677 | +If you want your code to be portable, your format (C<fmt>) argument | ||
| 5678 | +should use only the conversion specifiers defined by the ANSI C | ||
| 5679 | +standard (C89, to play safe). These are C<aAbBcdHIjmMpSUwWxXyYZ%>. | ||
| 5680 | +But even then, the B<results> of some of the conversion specifiers are | ||
| 5681 | +non-portable. For example, the specifiers C<aAbBcpZ> change according | ||
| 5682 | +to the locale settings of the user, and both how to set locales (the | ||
| 5683 | +locale names) and what output to expect are non-standard. | ||
| 5684 | +The specifier C<c> changes according to the timezone settings of the | ||
| 5685 | +user and the timezone computation rules of the operating system. | ||
| 5686 | +The C<Z> specifier is notoriously unportable since the names of | ||
| 5687 | +timezones are non-standard. Sticking to the numeric specifiers is the | ||
| 5688 | +safest route. | ||
| 5689 | + | ||
| 5690 | +The given arguments are made consistent as though by calling | ||
| 5691 | +C<mktime()> before calling your system's C<strftime()> function, | ||
| 5692 | +except that the C<isdst> value is not affected. | ||
| 5693 | + | ||
| 5694 | +The string for Tuesday, December 12, 1995. | ||
| 5695 | + | ||
| 5696 | + $str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 ); | ||
| 5697 | + print "$str\n"; | ||
| 5698 | + | ||
| 5699 | +=item strlen | ||
| 5700 | + | ||
| 5701 | +strlen() is C-specific, use C<length()> instead, see L<perlfunc/length>. | ||
| 5702 | + | ||
| 5703 | +=item strncat | ||
| 5704 | + | ||
| 5705 | +strncat() is C-specific, use C<.=> instead, see L<perlop>. | ||
| 5706 | + | ||
| 5707 | +=item strncmp | ||
| 5708 | + | ||
| 5709 | +strncmp() is C-specific, use C<eq> instead, see L<perlop>. | ||
| 5710 | + | ||
| 5711 | +=item strncpy | ||
| 5712 | + | ||
| 5713 | +strncpy() is C-specific, use C<=> instead, see L<perlop>. | ||
| 5714 | + | ||
| 5715 | +=item strpbrk | ||
| 5716 | + | ||
| 5717 | +strpbrk() is C-specific, use regular expressions instead, | ||
| 5718 | +see L<perlre>. | ||
| 5719 | + | ||
| 5720 | +=item strrchr | ||
| 5721 | + | ||
| 5722 | +strrchr() is C-specific, see L<perlfunc/rindex> instead. | ||
| 5723 | + | ||
| 5724 | +=item strspn | ||
| 5725 | + | ||
| 5726 | +strspn() is C-specific, use regular expressions instead, | ||
| 5727 | +see L<perlre>. | ||
| 5728 | + | ||
| 5729 | +=item strstr | ||
| 5730 | + | ||
| 5731 | +This is identical to Perl's builtin C<index()> function, | ||
| 5732 | +see L<perlfunc/index>. | ||
| 5733 | + | ||
| 5734 | +=item strtod | ||
| 5735 | + | ||
| 5736 | +String to double translation. Returns the parsed number and the number | ||
| 5737 | +of characters in the unparsed portion of the string. Truly | ||
| 5738 | +POSIX-compliant systems set $! ($ERRNO) to indicate a translation | ||
| 5739 | +error, so clear $! before calling strtod. However, non-POSIX systems | ||
| 5740 | +may not check for overflow, and therefore will never set $!. | ||
| 5741 | + | ||
| 5742 | +strtod should respect any POSIX I<setlocale()> settings. | ||
| 5743 | + | ||
| 5744 | +To parse a string $str as a floating point number use | ||
| 5745 | + | ||
| 5746 | + $! = 0; | ||
| 5747 | + ($num, $n_unparsed) = POSIX::strtod($str); | ||
| 5748 | + | ||
| 5749 | +The second returned item and $! can be used to check for valid input: | ||
| 5750 | + | ||
| 5751 | + if (($str eq '') || ($n_unparsed != 0) || $!) { | ||
| 5752 | + die "Non-numeric input $str" . ($! ? ": $!\n" : "\n"); | ||
| 5753 | + } | ||
| 5754 | + | ||
| 5755 | +When called in a scalar context strtod returns the parsed number. | ||
| 5756 | + | ||
| 5757 | +=item strtok | ||
| 5758 | + | ||
| 5759 | +strtok() is C-specific, use regular expressions instead, see | ||
| 5760 | +L<perlre>, or L<perlfunc/split>. | ||
| 5761 | + | ||
| 5762 | +=item strtol | ||
| 5763 | + | ||
| 5764 | +String to (long) integer translation. Returns the parsed number and | ||
| 5765 | +the number of characters in the unparsed portion of the string. Truly | ||
| 5766 | +POSIX-compliant systems set $! ($ERRNO) to indicate a translation | ||
| 5767 | +error, so clear $! before calling strtol. However, non-POSIX systems | ||
| 5768 | +may not check for overflow, and therefore will never set $!. | ||
| 5769 | + | ||
| 5770 | +strtol should respect any POSIX I<setlocale()> settings. | ||
| 5771 | + | ||
| 5772 | +To parse a string $str as a number in some base $base use | ||
| 5773 | + | ||
| 5774 | + $! = 0; | ||
| 5775 | + ($num, $n_unparsed) = POSIX::strtol($str, $base); | ||
| 5776 | + | ||
| 5777 | +The base should be zero or between 2 and 36, inclusive. When the base | ||
| 5778 | +is zero or omitted strtol will use the string itself to determine the | ||
| 5779 | +base: a leading "0x" or "0X" means hexadecimal; a leading "0" means | ||
| 5780 | +octal; any other leading characters mean decimal. Thus, "1234" is | ||
| 5781 | +parsed as a decimal number, "01234" as an octal number, and "0x1234" | ||
| 5782 | +as a hexadecimal number. | ||
| 5783 | + | ||
| 5784 | +The second returned item and $! can be used to check for valid input: | ||
| 5785 | + | ||
| 5786 | + if (($str eq '') || ($n_unparsed != 0) || !$!) { | ||
| 5787 | + die "Non-numeric input $str" . $! ? ": $!\n" : "\n"; | ||
| 5788 | + } | ||
| 5789 | + | ||
| 5790 | +When called in a scalar context strtol returns the parsed number. | ||
| 5791 | + | ||
| 5792 | +=item strtoul | ||
| 5793 | + | ||
| 5794 | +String to unsigned (long) integer translation. strtoul() is identical | ||
| 5795 | +to strtol() except that strtoul() only parses unsigned integers. See | ||
| 5796 | +L</strtol> for details. | ||
| 5797 | + | ||
| 5798 | +Note: Some vendors supply strtod() and strtol() but not strtoul(). | ||
| 5799 | +Other vendors that do supply strtoul() parse "-1" as a valid value. | ||
| 5800 | + | ||
| 5801 | +=item strxfrm | ||
| 5802 | + | ||
| 5803 | +String transformation. Returns the transformed string. | ||
| 5804 | + | ||
| 5805 | + $dst = POSIX::strxfrm( $src ); | ||
| 5806 | + | ||
| 5807 | +Used in conjunction with the C<strcoll()> function, see L</strcoll>. | ||
| 5808 | + | ||
| 5809 | +Not really needed since Perl can do this transparently, see | ||
| 5810 | +L<perllocale>. | ||
| 5811 | + | ||
| 5812 | +=item sysconf | ||
| 5813 | + | ||
| 5814 | +Retrieves values of system configurable variables. | ||
| 5815 | + | ||
| 5816 | +The following will get the machine's clock speed. | ||
| 5817 | + | ||
| 5818 | + $clock_ticks = POSIX::sysconf( &POSIX::_SC_CLK_TCK ); | ||
| 5819 | + | ||
| 5820 | +Returns C<undef> on failure. | ||
| 5821 | + | ||
| 5822 | +=item system | ||
| 5823 | + | ||
| 5824 | +This is identical to Perl's builtin C<system()> function, see | ||
| 5825 | +L<perlfunc/system>. | ||
| 5826 | + | ||
| 5827 | +=item tan | ||
| 5828 | + | ||
| 5829 | +This is identical to the C function C<tan()>, returning the | ||
| 5830 | +tangent of the numerical argument. See also L<Math::Trig>. | ||
| 5831 | + | ||
| 5832 | +=item tanh | ||
| 5833 | + | ||
| 5834 | +This is identical to the C function C<tanh()>, returning the | ||
| 5835 | +hyperbolic tangent of the numerical argument. See also L<Math::Trig>. | ||
| 5836 | + | ||
| 5837 | +=item tcdrain | ||
| 5838 | + | ||
| 5839 | +This is similar to the C function C<tcdrain()> for draining | ||
| 5840 | +the output queue of its argument stream. | ||
| 5841 | + | ||
| 5842 | +Returns C<undef> on failure. | ||
| 5843 | + | ||
| 5844 | +=item tcflow | ||
| 5845 | + | ||
| 5846 | +This is similar to the C function C<tcflow()> for controlling | ||
| 5847 | +the flow of its argument stream. | ||
| 5848 | + | ||
| 5849 | +Returns C<undef> on failure. | ||
| 5850 | + | ||
| 5851 | +=item tcflush | ||
| 5852 | + | ||
| 5853 | +This is similar to the C function C<tcflush()> for flushing | ||
| 5854 | +the I/O buffers of its argument stream. | ||
| 5855 | + | ||
| 5856 | +Returns C<undef> on failure. | ||
| 5857 | + | ||
| 5858 | +=item tcgetpgrp | ||
| 5859 | + | ||
| 5860 | +This is identical to the C function C<tcgetpgrp()> for returning the | ||
| 5861 | +process group identifier of the foreground process group of the controlling | ||
| 5862 | +terminal. | ||
| 5863 | + | ||
| 5864 | +=item tcsendbreak | ||
| 5865 | + | ||
| 5866 | +This is similar to the C function C<tcsendbreak()> for sending | ||
| 5867 | +a break on its argument stream. | ||
| 5868 | + | ||
| 5869 | +Returns C<undef> on failure. | ||
| 5870 | + | ||
| 5871 | +=item tcsetpgrp | ||
| 5872 | + | ||
| 5873 | +This is similar to the C function C<tcsetpgrp()> for setting the | ||
| 5874 | +process group identifier of the foreground process group of the controlling | ||
| 5875 | +terminal. | ||
| 5876 | + | ||
| 5877 | +Returns C<undef> on failure. | ||
| 5878 | + | ||
| 5879 | +=item time | ||
| 5880 | + | ||
| 5881 | +This is identical to Perl's builtin C<time()> function | ||
| 5882 | +for returning the number of seconds since the epoch | ||
| 5883 | +(whatever it is for the system), see L<perlfunc/time>. | ||
| 5884 | + | ||
| 5885 | +=item times | ||
| 5886 | + | ||
| 5887 | +The times() function returns elapsed realtime since some point in the past | ||
| 5888 | +(such as system startup), user and system times for this process, and user | ||
| 5889 | +and system times used by child processes. All times are returned in clock | ||
| 5890 | +ticks. | ||
| 5891 | + | ||
| 5892 | + ($realtime, $user, $system, $cuser, $csystem) = POSIX::times(); | ||
| 5893 | + | ||
| 5894 | +Note: Perl's builtin C<times()> function returns four values, measured in | ||
| 5895 | +seconds. | ||
| 5896 | + | ||
| 5897 | +=item tmpfile | ||
| 5898 | + | ||
| 5899 | +Use method C<IO::File::new_tmpfile()> instead, or see L<File::Temp>. | ||
| 5900 | + | ||
| 5901 | +=item tmpnam | ||
| 5902 | + | ||
| 5903 | +Returns a name for a temporary file. | ||
| 5904 | + | ||
| 5905 | + $tmpfile = POSIX::tmpnam(); | ||
| 5906 | + | ||
| 5907 | +For security reasons, which are probably detailed in your system's | ||
| 5908 | +documentation for the C library tmpnam() function, this interface | ||
| 5909 | +should not be used; instead see L<File::Temp>. | ||
| 5910 | + | ||
| 5911 | +=item tolower | ||
| 5912 | + | ||
| 5913 | +This is identical to the C function, except that it can apply to a single | ||
| 5914 | +character or to a whole string. Consider using the C<lc()> function, | ||
| 5915 | +see L<perlfunc/lc>, or the equivalent C<\L> operator inside doublequotish | ||
| 5916 | +strings. | ||
| 5917 | + | ||
| 5918 | +=item toupper | ||
| 5919 | + | ||
| 5920 | +This is identical to the C function, except that it can apply to a single | ||
| 5921 | +character or to a whole string. Consider using the C<uc()> function, | ||
| 5922 | +see L<perlfunc/uc>, or the equivalent C<\U> operator inside doublequotish | ||
| 5923 | +strings. | ||
| 5924 | + | ||
| 5925 | +=item ttyname | ||
| 5926 | + | ||
| 5927 | +This is identical to the C function C<ttyname()> for returning the | ||
| 5928 | +name of the current terminal. | ||
| 5929 | + | ||
| 5930 | +=item tzname | ||
| 5931 | + | ||
| 5932 | +Retrieves the time conversion information from the C<tzname> variable. | ||
| 5933 | + | ||
| 5934 | + POSIX::tzset(); | ||
| 5935 | + ($std, $dst) = POSIX::tzname(); | ||
| 5936 | + | ||
| 5937 | +=item tzset | ||
| 5938 | + | ||
| 5939 | +This is identical to the C function C<tzset()> for setting | ||
| 5940 | +the current timezone based on the environment variable C<TZ>, | ||
| 5941 | +to be used by C<ctime()>, C<localtime()>, C<mktime()>, and C<strftime()> | ||
| 5942 | +functions. | ||
| 5943 | + | ||
| 5944 | +=item umask | ||
| 5945 | + | ||
| 5946 | +This is identical to Perl's builtin C<umask()> function | ||
| 5947 | +for setting (and querying) the file creation permission mask, | ||
| 5948 | +see L<perlfunc/umask>. | ||
| 5949 | + | ||
| 5950 | +=item uname | ||
| 5951 | + | ||
| 5952 | +Get name of current operating system. | ||
| 5953 | + | ||
| 5954 | + ($sysname, $nodename, $release, $version, $machine) = POSIX::uname(); | ||
| 5955 | + | ||
| 5956 | +Note that the actual meanings of the various fields are not | ||
| 5957 | +that well standardized, do not expect any great portability. | ||
| 5958 | +The C<$sysname> might be the name of the operating system, | ||
| 5959 | +the C<$nodename> might be the name of the host, the C<$release> | ||
| 5960 | +might be the (major) release number of the operating system, | ||
| 5961 | +the C<$version> might be the (minor) release number of the | ||
| 5962 | +operating system, and the C<$machine> might be a hardware identifier. | ||
| 5963 | +Maybe. | ||
| 5964 | + | ||
| 5965 | +=item ungetc | ||
| 5966 | + | ||
| 5967 | +Use method C<IO::Handle::ungetc()> instead. | ||
| 5968 | + | ||
| 5969 | +=item unlink | ||
| 5970 | + | ||
| 5971 | +This is identical to Perl's builtin C<unlink()> function | ||
| 5972 | +for removing files, see L<perlfunc/unlink>. | ||
| 5973 | + | ||
| 5974 | +=item utime | ||
| 5975 | + | ||
| 5976 | +This is identical to Perl's builtin C<utime()> function | ||
| 5977 | +for changing the time stamps of files and directories, | ||
| 5978 | +see L<perlfunc/utime>. | ||
| 5979 | + | ||
| 5980 | +=item vfprintf | ||
| 5981 | + | ||
| 5982 | +vfprintf() is C-specific, see L<perlfunc/printf> instead. | ||
| 5983 | + | ||
| 5984 | +=item vprintf | ||
| 5985 | + | ||
| 5986 | +vprintf() is C-specific, see L<perlfunc/printf> instead. | ||
| 5987 | + | ||
| 5988 | +=item vsprintf | ||
| 5989 | + | ||
| 5990 | +vsprintf() is C-specific, see L<perlfunc/sprintf> instead. | ||
| 5991 | + | ||
| 5992 | +=item wait | ||
| 5993 | + | ||
| 5994 | +This is identical to Perl's builtin C<wait()> function, | ||
| 5995 | +see L<perlfunc/wait>. | ||
| 5996 | + | ||
| 5997 | +=item waitpid | ||
| 5998 | + | ||
| 5999 | +Wait for a child process to change state. This is identical to Perl's | ||
| 6000 | +builtin C<waitpid()> function, see L<perlfunc/waitpid>. | ||
| 6001 | + | ||
| 6002 | + $pid = POSIX::waitpid( -1, POSIX::WNOHANG ); | ||
| 6003 | + print "status = ", ($? / 256), "\n"; | ||
| 6004 | + | ||
| 6005 | +=item wcstombs | ||
| 6006 | + | ||
| 6007 | +This is identical to the C function C<wcstombs()>. | ||
| 6008 | +Perl does not have any support for the wide and multibyte | ||
| 6009 | +characters of the C standards, so this might be a rather | ||
| 6010 | +useless function. | ||
| 6011 | + | ||
| 6012 | +=item wctomb | ||
| 6013 | + | ||
| 6014 | +This is identical to the C function C<wctomb()>. | ||
| 6015 | +Perl does not have any support for the wide and multibyte | ||
| 6016 | +characters of the C standards, so this might be a rather | ||
| 6017 | +useless function. | ||
| 6018 | + | ||
| 6019 | +=item write | ||
| 6020 | + | ||
| 6021 | +Write to a file. This uses file descriptors such as those obtained by | ||
| 6022 | +calling C<POSIX::open>. | ||
| 6023 | + | ||
| 6024 | + $fd = POSIX::open( "foo", &POSIX::O_WRONLY ); | ||
| 6025 | + $buf = "hello"; | ||
| 6026 | + $bytes = POSIX::write( $fd, $buf, 5 ); | ||
| 6027 | + | ||
| 6028 | +Returns C<undef> on failure. | ||
| 6029 | + | ||
| 6030 | +See also L<perlfunc/syswrite>. | ||
| 6031 | + | ||
| 6032 | +=back | ||
| 6033 | + | ||
| 6034 | +=head1 CLASSES | ||
| 6035 | + | ||
| 6036 | +=head2 POSIX::SigAction | ||
| 6037 | + | ||
| 6038 | +=over 8 | ||
| 6039 | + | ||
| 6040 | +=item new | ||
| 6041 | + | ||
| 6042 | +Creates a new C<POSIX::SigAction> object which corresponds to the C | ||
| 6043 | +C<struct sigaction>. This object will be destroyed automatically when | ||
| 6044 | +it is no longer needed. The first parameter is the handler, a sub | ||
| 6045 | +reference. The second parameter is a C<POSIX::SigSet> object, it | ||
| 6046 | +defaults to the empty set. The third parameter contains the | ||
| 6047 | +C<sa_flags>, it defaults to 0. | ||
| 6048 | + | ||
| 6049 | + $sigset = POSIX::SigSet->new(SIGINT, SIGQUIT); | ||
| 6050 | + $sigaction = POSIX::SigAction->new( \&handler, $sigset, &POSIX::SA_NOCLDSTOP ); | ||
| 6051 | + | ||
| 6052 | +This C<POSIX::SigAction> object is intended for use with the C<POSIX::sigaction()> | ||
| 6053 | +function. | ||
| 6054 | + | ||
| 6055 | +=back | ||
| 6056 | + | ||
| 6057 | +=over 8 | ||
| 6058 | + | ||
| 6059 | +=item handler | ||
| 6060 | + | ||
| 6061 | +=item mask | ||
| 6062 | + | ||
| 6063 | +=item flags | ||
| 6064 | + | ||
| 6065 | +accessor functions to get/set the values of a SigAction object. | ||
| 6066 | + | ||
| 6067 | + $sigset = $sigaction->mask; | ||
| 6068 | + $sigaction->flags(&POSIX::SA_RESTART); | ||
| 6069 | + | ||
| 6070 | +=item safe | ||
| 6071 | + | ||
| 6072 | +accessor function for the "safe signals" flag of a SigAction object; see | ||
| 6073 | +L<perlipc> for general information on safe (a.k.a. "deferred") signals. If | ||
| 6074 | +you wish to handle a signal safely, use this accessor to set the "safe" flag | ||
| 6075 | +in the C<POSIX::SigAction> object: | ||
| 6076 | + | ||
| 6077 | + $sigaction->safe(1); | ||
| 6078 | + | ||
| 6079 | +You may also examine the "safe" flag on the output action object which is | ||
| 6080 | +filled in when given as the third parameter to C<POSIX::sigaction()>: | ||
| 6081 | + | ||
| 6082 | + sigaction(SIGINT, $new_action, $old_action); | ||
| 6083 | + if ($old_action->safe) { | ||
| 6084 | + # previous SIGINT handler used safe signals | ||
| 6085 | + } | ||
| 6086 | + | ||
| 6087 | +=back | ||
| 6088 | + | ||
| 6089 | +=head2 POSIX::SigRt | ||
| 6090 | + | ||
| 6091 | +=over 8 | ||
| 6092 | + | ||
| 6093 | +=item %SIGRT | ||
| 6094 | + | ||
| 6095 | +A hash of the POSIX realtime signal handlers. It is an extension of | ||
| 6096 | +the standard %SIG, the $POSIX::SIGRT{SIGRTMIN} is roughly equivalent | ||
| 6097 | +to $SIG{SIGRTMIN}, but the right POSIX moves (see below) are made with | ||
| 6098 | +the POSIX::SigSet and POSIX::sigaction instead of accessing the %SIG. | ||
| 6099 | + | ||
| 6100 | +You can set the %POSIX::SIGRT elements to set the POSIX realtime | ||
| 6101 | +signal handlers, use C<delete> and C<exists> on the elements, and use | ||
| 6102 | +C<scalar> on the C<%POSIX::SIGRT> to find out how many POSIX realtime | ||
| 6103 | +signals there are available (SIGRTMAX - SIGRTMIN + 1, the SIGRTMAX is | ||
| 6104 | +a valid POSIX realtime signal). | ||
| 6105 | + | ||
| 6106 | +Setting the %SIGRT elements is equivalent to calling this: | ||
| 6107 | + | ||
| 6108 | + sub new { | ||
| 6109 | + my ($rtsig, $handler, $flags) = @_; | ||
| 6110 | + my $sigset = POSIX::SigSet($rtsig); | ||
| 6111 | + my $sigact = POSIX::SigAction->new($handler, $sigset, $flags); | ||
| 6112 | + sigaction($rtsig, $sigact); | ||
| 6113 | + } | ||
| 6114 | + | ||
| 6115 | +The flags default to zero, if you want something different you can | ||
| 6116 | +either use C<local> on $POSIX::SigRt::SIGACTION_FLAGS, or you can | ||
| 6117 | +derive from POSIX::SigRt and define your own C<new()> (the tied hash | ||
| 6118 | +STORE method of the %SIGRT calls C<new($rtsig, $handler, $SIGACTION_FLAGS)>, | ||
| 6119 | +where the $rtsig ranges from zero to SIGRTMAX - SIGRTMIN + 1). | ||
| 6120 | + | ||
| 6121 | +Just as with any signal, you can use sigaction($rtsig, undef, $oa) to | ||
| 6122 | +retrieve the installed signal handler (or, rather, the signal action). | ||
| 6123 | + | ||
| 6124 | +B<NOTE:> whether POSIX realtime signals really work in your system, or | ||
| 6125 | +whether Perl has been compiled so that it works with them, is outside | ||
| 6126 | +of this discussion. | ||
| 6127 | + | ||
| 6128 | +=item SIGRTMIN | ||
| 6129 | + | ||
| 6130 | +Return the minimum POSIX realtime signal number available, or C<undef> | ||
| 6131 | +if no POSIX realtime signals are available. | ||
| 6132 | + | ||
| 6133 | +=item SIGRTMAX | ||
| 6134 | + | ||
| 6135 | +Return the maximum POSIX realtime signal number available, or C<undef> | ||
| 6136 | +if no POSIX realtime signals are available. | ||
| 6137 | + | ||
| 6138 | +=back | ||
| 6139 | + | ||
| 6140 | +=head2 POSIX::SigSet | ||
| 6141 | + | ||
| 6142 | +=over 8 | ||
| 6143 | + | ||
| 6144 | +=item new | ||
| 6145 | + | ||
| 6146 | +Create a new SigSet object. This object will be destroyed automatically | ||
| 6147 | +when it is no longer needed. Arguments may be supplied to initialize the | ||
| 6148 | +set. | ||
| 6149 | + | ||
| 6150 | +Create an empty set. | ||
| 6151 | + | ||
| 6152 | + $sigset = POSIX::SigSet->new; | ||
| 6153 | + | ||
| 6154 | +Create a set with SIGUSR1. | ||
| 6155 | + | ||
| 6156 | + $sigset = POSIX::SigSet->new( &POSIX::SIGUSR1 ); | ||
| 6157 | + | ||
| 6158 | +=item addset | ||
| 6159 | + | ||
| 6160 | +Add a signal to a SigSet object. | ||
| 6161 | + | ||
| 6162 | + $sigset->addset( &POSIX::SIGUSR2 ); | ||
| 6163 | + | ||
| 6164 | +Returns C<undef> on failure. | ||
| 6165 | + | ||
| 6166 | +=item delset | ||
| 6167 | + | ||
| 6168 | +Remove a signal from the SigSet object. | ||
| 6169 | + | ||
| 6170 | + $sigset->delset( &POSIX::SIGUSR2 ); | ||
| 6171 | + | ||
| 6172 | +Returns C<undef> on failure. | ||
| 6173 | + | ||
| 6174 | +=item emptyset | ||
| 6175 | + | ||
| 6176 | +Initialize the SigSet object to be empty. | ||
| 6177 | + | ||
| 6178 | + $sigset->emptyset(); | ||
| 6179 | + | ||
| 6180 | +Returns C<undef> on failure. | ||
| 6181 | + | ||
| 6182 | +=item fillset | ||
| 6183 | + | ||
| 6184 | +Initialize the SigSet object to include all signals. | ||
| 6185 | + | ||
| 6186 | + $sigset->fillset(); | ||
| 6187 | + | ||
| 6188 | +Returns C<undef> on failure. | ||
| 6189 | + | ||
| 6190 | +=item ismember | ||
| 6191 | + | ||
| 6192 | +Tests the SigSet object to see if it contains a specific signal. | ||
| 6193 | + | ||
| 6194 | + if( $sigset->ismember( &POSIX::SIGUSR1 ) ){ | ||
| 6195 | + print "contains SIGUSR1\n"; | ||
| 6196 | + } | ||
| 6197 | + | ||
| 6198 | +=back | ||
| 6199 | + | ||
| 6200 | +=head2 POSIX::Termios | ||
| 6201 | + | ||
| 6202 | +=over 8 | ||
| 6203 | + | ||
| 6204 | +=item new | ||
| 6205 | + | ||
| 6206 | +Create a new Termios object. This object will be destroyed automatically | ||
| 6207 | +when it is no longer needed. A Termios object corresponds to the termios | ||
| 6208 | +C struct. new() mallocs a new one, getattr() fills it from a file descriptor, | ||
| 6209 | +and setattr() sets a file descriptor's parameters to match Termios' contents. | ||
| 6210 | + | ||
| 6211 | + $termios = POSIX::Termios->new; | ||
| 6212 | + | ||
| 6213 | +=item getattr | ||
| 6214 | + | ||
| 6215 | +Get terminal control attributes. | ||
| 6216 | + | ||
| 6217 | +Obtain the attributes for stdin. | ||
| 6218 | + | ||
| 6219 | + $termios->getattr( 0 ) # Recommended for clarity. | ||
| 6220 | + $termios->getattr() | ||
| 6221 | + | ||
| 6222 | +Obtain the attributes for stdout. | ||
| 6223 | + | ||
| 6224 | + $termios->getattr( 1 ) | ||
| 6225 | + | ||
| 6226 | +Returns C<undef> on failure. | ||
| 6227 | + | ||
| 6228 | +=item getcc | ||
| 6229 | + | ||
| 6230 | +Retrieve a value from the c_cc field of a termios object. The c_cc field is | ||
| 6231 | +an array so an index must be specified. | ||
| 6232 | + | ||
| 6233 | + $c_cc[1] = $termios->getcc(1); | ||
| 6234 | + | ||
| 6235 | +=item getcflag | ||
| 6236 | + | ||
| 6237 | +Retrieve the c_cflag field of a termios object. | ||
| 6238 | + | ||
| 6239 | + $c_cflag = $termios->getcflag; | ||
| 6240 | + | ||
| 6241 | +=item getiflag | ||
| 6242 | + | ||
| 6243 | +Retrieve the c_iflag field of a termios object. | ||
| 6244 | + | ||
| 6245 | + $c_iflag = $termios->getiflag; | ||
| 6246 | + | ||
| 6247 | +=item getispeed | ||
| 6248 | + | ||
| 6249 | +Retrieve the input baud rate. | ||
| 6250 | + | ||
| 6251 | + $ispeed = $termios->getispeed; | ||
| 6252 | + | ||
| 6253 | +=item getlflag | ||
| 6254 | + | ||
| 6255 | +Retrieve the c_lflag field of a termios object. | ||
| 6256 | + | ||
| 6257 | + $c_lflag = $termios->getlflag; | ||
| 6258 | + | ||
| 6259 | +=item getoflag | ||
| 6260 | + | ||
| 6261 | +Retrieve the c_oflag field of a termios object. | ||
| 6262 | + | ||
| 6263 | + $c_oflag = $termios->getoflag; | ||
| 6264 | + | ||
| 6265 | +=item getospeed | ||
| 6266 | + | ||
| 6267 | +Retrieve the output baud rate. | ||
| 6268 | + | ||
| 6269 | + $ospeed = $termios->getospeed; | ||
| 6270 | + | ||
| 6271 | +=item setattr | ||
| 6272 | + | ||
| 6273 | +Set terminal control attributes. | ||
| 6274 | + | ||
| 6275 | +Set attributes immediately for stdout. | ||
| 6276 | + | ||
| 6277 | + $termios->setattr( 1, &POSIX::TCSANOW ); | ||
| 6278 | + | ||
| 6279 | +Returns C<undef> on failure. | ||
| 6280 | + | ||
| 6281 | +=item setcc | ||
| 6282 | + | ||
| 6283 | +Set a value in the c_cc field of a termios object. The c_cc field is an | ||
| 6284 | +array so an index must be specified. | ||
| 6285 | + | ||
| 6286 | + $termios->setcc( &POSIX::VEOF, 1 ); | ||
| 6287 | + | ||
| 6288 | +=item setcflag | ||
| 6289 | + | ||
| 6290 | +Set the c_cflag field of a termios object. | ||
| 6291 | + | ||
| 6292 | + $termios->setcflag( $c_cflag | &POSIX::CLOCAL ); | ||
| 6293 | + | ||
| 6294 | +=item setiflag | ||
| 6295 | + | ||
| 6296 | +Set the c_iflag field of a termios object. | ||
| 6297 | + | ||
| 6298 | + $termios->setiflag( $c_iflag | &POSIX::BRKINT ); | ||
| 6299 | + | ||
| 6300 | +=item setispeed | ||
| 6301 | + | ||
| 6302 | +Set the input baud rate. | ||
| 6303 | + | ||
| 6304 | + $termios->setispeed( &POSIX::B9600 ); | ||
| 6305 | + | ||
| 6306 | +Returns C<undef> on failure. | ||
| 6307 | + | ||
| 6308 | +=item setlflag | ||
| 6309 | + | ||
| 6310 | +Set the c_lflag field of a termios object. | ||
| 6311 | + | ||
| 6312 | + $termios->setlflag( $c_lflag | &POSIX::ECHO ); | ||
| 6313 | + | ||
| 6314 | +=item setoflag | ||
| 6315 | + | ||
| 6316 | +Set the c_oflag field of a termios object. | ||
| 6317 | + | ||
| 6318 | + $termios->setoflag( $c_oflag | &POSIX::OPOST ); | ||
| 6319 | + | ||
| 6320 | +=item setospeed | ||
| 6321 | + | ||
| 6322 | +Set the output baud rate. | ||
| 6323 | + | ||
| 6324 | + $termios->setospeed( &POSIX::B9600 ); | ||
| 6325 | + | ||
| 6326 | +Returns C<undef> on failure. | ||
| 6327 | + | ||
| 6328 | +=item Baud rate values | ||
| 6329 | + | ||
| 6330 | +B38400 B75 B200 B134 B300 B1800 B150 B0 B19200 B1200 B9600 B600 B4800 B50 B2400 B110 | ||
| 6331 | + | ||
| 6332 | +=item Terminal interface values | ||
| 6333 | + | ||
| 6334 | +TCSADRAIN TCSANOW TCOON TCIOFLUSH TCOFLUSH TCION TCIFLUSH TCSAFLUSH TCIOFF TCOOFF | ||
| 6335 | + | ||
| 6336 | +=item c_cc field values | ||
| 6337 | + | ||
| 6338 | +VEOF VEOL VERASE VINTR VKILL VQUIT VSUSP VSTART VSTOP VMIN VTIME NCCS | ||
| 6339 | + | ||
| 6340 | +=item c_cflag field values | ||
| 6341 | + | ||
| 6342 | +CLOCAL CREAD CSIZE CS5 CS6 CS7 CS8 CSTOPB HUPCL PARENB PARODD | ||
| 6343 | + | ||
| 6344 | +=item c_iflag field values | ||
| 6345 | + | ||
| 6346 | +BRKINT ICRNL IGNBRK IGNCR IGNPAR INLCR INPCK ISTRIP IXOFF IXON PARMRK | ||
| 6347 | + | ||
| 6348 | +=item c_lflag field values | ||
| 6349 | + | ||
| 6350 | +ECHO ECHOE ECHOK ECHONL ICANON IEXTEN ISIG NOFLSH TOSTOP | ||
| 6351 | + | ||
| 6352 | +=item c_oflag field values | ||
| 6353 | + | ||
| 6354 | +OPOST | ||
| 6355 | + | ||
| 6356 | +=back | ||
| 6357 | + | ||
| 6358 | +=head1 PATHNAME CONSTANTS | ||
| 6359 | + | ||
| 6360 | +=over 8 | ||
| 6361 | + | ||
| 6362 | +=item Constants | ||
| 6363 | + | ||
| 6364 | +_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 | ||
| 6365 | + | ||
| 6366 | +=back | ||
| 6367 | + | ||
| 6368 | +=head1 POSIX CONSTANTS | ||
| 6369 | + | ||
| 6370 | +=over 8 | ||
| 6371 | + | ||
| 6372 | +=item Constants | ||
| 6373 | + | ||
| 6374 | +_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 | ||
| 6375 | + | ||
| 6376 | +=back | ||
| 6377 | + | ||
| 6378 | +=head1 SYSTEM CONFIGURATION | ||
| 6379 | + | ||
| 6380 | +=over 8 | ||
| 6381 | + | ||
| 6382 | +=item Constants | ||
| 6383 | + | ||
| 6384 | +_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 | ||
| 6385 | + | ||
| 6386 | +=back | ||
| 6387 | + | ||
| 6388 | +=head1 ERRNO | ||
| 6389 | + | ||
| 6390 | +=over 8 | ||
| 6391 | + | ||
| 6392 | +=item Constants | ||
| 6393 | + | ||
| 6394 | +E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT EAGAIN EALREADY EBADF | ||
| 6395 | +EBUSY ECHILD ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ | ||
| 6396 | +EDOM EDQUOT EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH EINPROGRESS EINTR | ||
| 6397 | +EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE ENAMETOOLONG | ||
| 6398 | +ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODEV ENOENT ENOEXEC | ||
| 6399 | +ENOLCK ENOMEM ENOPROTOOPT ENOSPC ENOSYS ENOTBLK ENOTCONN ENOTDIR | ||
| 6400 | +ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM EPFNOSUPPORT EPIPE | ||
| 6401 | +EPROCLIM EPROTONOSUPPORT EPROTOTYPE ERANGE EREMOTE ERESTART EROFS | ||
| 6402 | +ESHUTDOWN ESOCKTNOSUPPORT ESPIPE ESRCH ESTALE ETIMEDOUT ETOOMANYREFS | ||
| 6403 | +ETXTBSY EUSERS EWOULDBLOCK EXDEV | ||
| 6404 | + | ||
| 6405 | +=back | ||
| 6406 | + | ||
| 6407 | +=head1 FCNTL | ||
| 6408 | + | ||
| 6409 | +=over 8 | ||
| 6410 | + | ||
| 6411 | +=item Constants | ||
| 6412 | + | ||
| 6413 | +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 | ||
| 6414 | + | ||
| 6415 | +=back | ||
| 6416 | + | ||
| 6417 | +=head1 FLOAT | ||
| 6418 | + | ||
| 6419 | +=over 8 | ||
| 6420 | + | ||
| 6421 | +=item Constants | ||
| 6422 | + | ||
| 6423 | +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 | ||
| 6424 | + | ||
| 6425 | +=back | ||
| 6426 | + | ||
| 6427 | +=head1 LIMITS | ||
| 6428 | + | ||
| 6429 | +=over 8 | ||
| 6430 | + | ||
| 6431 | +=item Constants | ||
| 6432 | + | ||
| 6433 | +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 | ||
| 6434 | + | ||
| 6435 | +=back | ||
| 6436 | + | ||
| 6437 | +=head1 LOCALE | ||
| 6438 | + | ||
| 6439 | +=over 8 | ||
| 6440 | + | ||
| 6441 | +=item Constants | ||
| 6442 | + | ||
| 6443 | +LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME | ||
| 6444 | + | ||
| 6445 | +=back | ||
| 6446 | + | ||
| 6447 | +=head1 MATH | ||
| 6448 | + | ||
| 6449 | +=over 8 | ||
| 6450 | + | ||
| 6451 | +=item Constants | ||
| 6452 | + | ||
| 6453 | +HUGE_VAL | ||
| 6454 | + | ||
| 6455 | +=back | ||
| 6456 | + | ||
| 6457 | +=head1 SIGNAL | ||
| 6458 | + | ||
| 6459 | +=over 8 | ||
| 6460 | + | ||
| 6461 | +=item Constants | ||
| 6462 | + | ||
| 6463 | +SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK SA_RESETHAND SA_RESTART | ||
| 6464 | +SA_SIGINFO SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT | ||
| 6465 | +SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU | ||
| 6466 | +SIGUSR1 SIGUSR2 SIG_BLOCK SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK | ||
| 6467 | +SIG_UNBLOCK | ||
| 6468 | + | ||
| 6469 | +=back | ||
| 6470 | + | ||
| 6471 | +=head1 STAT | ||
| 6472 | + | ||
| 6473 | +=over 8 | ||
| 6474 | + | ||
| 6475 | +=item Constants | ||
| 6476 | + | ||
| 6477 | +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 | ||
| 6478 | + | ||
| 6479 | +=item Macros | ||
| 6480 | + | ||
| 6481 | +S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG | ||
| 6482 | + | ||
| 6483 | +=back | ||
| 6484 | + | ||
| 6485 | +=head1 STDLIB | ||
| 6486 | + | ||
| 6487 | +=over 8 | ||
| 6488 | + | ||
| 6489 | +=item Constants | ||
| 6490 | + | ||
| 6491 | +EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX RAND_MAX | ||
| 6492 | + | ||
| 6493 | +=back | ||
| 6494 | + | ||
| 6495 | +=head1 STDIO | ||
| 6496 | + | ||
| 6497 | +=over 8 | ||
| 6498 | + | ||
| 6499 | +=item Constants | ||
| 6500 | + | ||
| 6501 | +BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid L_tmpname TMP_MAX | ||
| 6502 | + | ||
| 6503 | +=back | ||
| 6504 | + | ||
| 6505 | +=head1 TIME | ||
| 6506 | + | ||
| 6507 | +=over 8 | ||
| 6508 | + | ||
| 6509 | +=item Constants | ||
| 6510 | + | ||
| 6511 | +CLK_TCK CLOCKS_PER_SEC | ||
| 6512 | + | ||
| 6513 | +=back | ||
| 6514 | + | ||
| 6515 | +=head1 UNISTD | ||
| 6516 | + | ||
| 6517 | +=over 8 | ||
| 6518 | + | ||
| 6519 | +=item Constants | ||
| 6520 | + | ||
| 6521 | +R_OK SEEK_CUR SEEK_END SEEK_SET STDIN_FILENO STDOUT_FILENO STDERR_FILENO W_OK X_OK | ||
| 6522 | + | ||
| 6523 | +=back | ||
| 6524 | + | ||
| 6525 | +=head1 WAIT | ||
| 6526 | + | ||
| 6527 | +=over 8 | ||
| 6528 | + | ||
| 6529 | +=item Constants | ||
| 6530 | + | ||
| 6531 | +WNOHANG WUNTRACED | ||
| 6532 | + | ||
| 6533 | +=over 16 | ||
| 6534 | + | ||
| 6535 | +=item WNOHANG | ||
| 6536 | + | ||
| 6537 | +Do not suspend the calling process until a child process | ||
| 6538 | +changes state but instead return immediately. | ||
| 6539 | + | ||
| 6540 | +=item WUNTRACED | ||
| 6541 | + | ||
| 6542 | +Catch stopped child processes. | ||
| 6543 | + | ||
| 6544 | +=back | ||
| 6545 | + | ||
| 6546 | +=item Macros | ||
| 6547 | + | ||
| 6548 | +WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG | ||
| 6549 | + | ||
| 6550 | +=over 16 | ||
| 6551 | + | ||
| 6552 | +=item WIFEXITED | ||
| 6553 | + | ||
| 6554 | +WIFEXITED($?) returns true if the child process exited normally | ||
| 6555 | +(C<exit()> or by falling off the end of C<main()>) | ||
| 6556 | + | ||
| 6557 | +=item WEXITSTATUS | ||
| 6558 | + | ||
| 6559 | +WEXITSTATUS($?) returns the normal exit status of the child process | ||
| 6560 | +(only meaningful if WIFEXITED($?) is true) | ||
| 6561 | + | ||
| 6562 | +=item WIFSIGNALED | ||
| 6563 | + | ||
| 6564 | +WIFSIGNALED($?) returns true if the child process terminated because | ||
| 6565 | +of a signal | ||
| 6566 | + | ||
| 6567 | +=item WTERMSIG | ||
| 6568 | + | ||
| 6569 | +WTERMSIG($?) returns the signal the child process terminated for | ||
| 6570 | +(only meaningful if WIFSIGNALED($?) is true) | ||
| 6571 | + | ||
| 6572 | +=item WIFSTOPPED | ||
| 6573 | + | ||
| 6574 | +WIFSTOPPED($?) returns true if the child process is currently stopped | ||
| 6575 | +(can happen only if you specified the WUNTRACED flag to waitpid()) | ||
| 6576 | + | ||
| 6577 | +=item WSTOPSIG | ||
| 6578 | + | ||
| 6579 | +WSTOPSIG($?) returns the signal the child process was stopped for | ||
| 6580 | +(only meaningful if WIFSTOPPED($?) is true) | ||
| 6581 | + | ||
| 6582 | +=back | ||
| 6583 | + | ||
| 6584 | +=back | ||
| 6585 | + | ||
