1POSIX::2008(3) User Contributed Perl Documentation POSIX::2008(3)
2
3
4
6 POSIX::2008 - Perl interface to POSIX.1-2008
7
9 use Fcntl;
10 use POSIX::2008 qw(openat pwrite);
11
12 sysopen my $dh, '/tmp', O_RDONLY|O_DIRECTORY|O_NOFOLLOW or die 'Dafuq?';
13 my $fh = openat($dh, 'foobar', O_RDWR|O_CREAT);
14 pwrite($fh, 'fuckyounsa', 10, 0);
15
17 POSIX::2008 contains many of the interfaces specified by POSIX.1-2008
18 <https://pubs.opengroup.org/onlinepubs/9699919799/> that the core POSIX
19 module withholds, implements in Perl or fucked up.
20
21 This module is provided "as is" unless someone volunteers to maintain
22 it.
23
25 Since version 0.13, the parameter order of pread/pwrite is (count,
26 offset) as with the actual system calls instead of (offset, count).
27 Good luck.
28
30 Since version 0.05, all I/O functions that take numeric file
31 descriptors also accept Perl file or directory handles. openat() even
32 returns a handle if you passed it one.
33
35 A system call return value of -1 meaning "error" is mapped to undef.
36
37 A system call return value of 0 meaning "success" is mapped to "0 but
38 true".
39
40 For system calls where 0 does not just mean "success", 0 is returned
41 unchanged. These are open(), read(), write(), readv(), writev(),
42 pread(), pwrite(), preadv(), pwritev(). openat() gets a special
43 treatment in this module, see below.
44
46 a64l
47 l = a64l(s);
48
49 abort
50 abort();
51
52 abs ui = abs(i);
53
54 access
55 ret = access(path, mode);
56
57 acos
58 y = acos(x);
59
60 acosh
61 y = acosh(x);
62
63 alarm
64 remaining_sec = alarm(sec);
65
66 asin
67 y = asin(x);
68
69 asinh
70 y = asinh(x);
71
72 atan2
73 z = atan2(y, x);
74
75 atan
76 y = atan(x);
77
78 atanh
79 y = atanh(x);
80
81 atof
82 f = atof(s);
83
84 atoi
85 i = atoi(s);
86
87 atol
88 l = atol(s);
89
90 atoll
91 ll = atoll(s);
92
93 basename
94 s = basename(path);
95
96 cabs
97 r = cabs(re, im);
98
99 cacos
100 (re, im) = cacos(re, im);
101
102 cacosh
103 (re, im) = cacosh(re, im);
104
105 carg
106 phi = carg(re, im);
107
108 casinh
109 (re, im) = casinh(re, im);
110
111 catan
112 (re, im) = catan(re, im);
113
114 catanh
115 (re, im) = catanh(re, im);
116
117 catclose
118 ret = catclose(catd);
119
120 catgets
121 s = catgets(catd, set_id, msg_id, dflt_string);
122
123 catopen
124 catd = catopen(name, oflag);
125
126 cbrt
127 y = cbrt(x);
128
129 ccos
130 (re, im) = ccos(re, im);
131
132 ccosh
133 (re, im) = ccosh(re, im);
134
135 ceil
136 y = ceil(x);
137
138 cexp
139 (re, im) = cexp(re, im);
140
141 chdir
142 ret = chdir(path);
143
144 chmod
145 ret = chmod(path, mode);
146
147 chown
148 ret = chown(path, uid, gid);
149
150 cimag
151 im = cimag(re, im);
152
153 clock
154 t = clock()
155
156 clock_getcpuclockid
157 clock_id = clock_getcpuclockid(pid);
158
159 pid defaults to $$. Returns undef on error.
160
161 clock_getres
162 (sec, nsec) = clock_getres(clock_id);
163
164 clock_id defaults to CLOCK_REALTIME. Returns empty list on error.
165
166 clock_gettime
167 (sec, nsec) = clock_gettime(clock_id);
168
169 clock_id defaults to CLOCK_REALTIME. Returns empty list on error.
170
171 clock_nanosleep
172 (rem_sec, rem_nsec) = clock_nanosleep(clock_id, flags, sec, nsec);
173
174 In scalar context returns the remaining seconds as a floating point
175 number.
176
177 clock_settime
178 ret = clock_settime(clock_id, sec, nsec);
179
180 clog
181 (re, im) = clog(re, im);
182
183 close
184 ret = close(fd);
185
186 confstr
187 s = confstr(name);
188
189 name is one of the _CS_ integer constants.
190
191 conj
192 (re, im) = conj(re, im);
193
194 copysign
195 xs = copysign(x, y);
196
197 cos y = cos(x);
198
199 cosh
200 y = cosh(x);
201
202 cpow
203 (re, im) = cpow(re_x, im_x, re_y, im_y);
204
205 cproj
206 (re, im) = cproj(re, im);
207
208 creal
209 re = creal(re, im);
210
211 csin
212 (re, im) = csin(re, im);
213
214 csinh
215 (re, im) = csinh(re, im);
216
217 csqrt
218 (re, im) = csqrt(re, im);
219
220 ctan
221 (re, im) = ctan(re, im);
222
223 ctanh
224 (re, im) = ctanh(re, im);
225
226 dirname
227 name = dirname(path);
228
229 div (quot, rem) = div(numer, denom);
230
231 dlclose
232 dlclose(dlhandle);
233
234 dlerror
235 dlerror();
236
237 dlopen
238 dlhandle = dlopen(file, mode);
239
240 dlsym
241 addr = dlsym(dlhandle, name);
242
243 drand48
244 r = drand48();
245
246 endutxent
247 endutxent();
248
249 erand48
250 (r, X0, X1, X2) = erand48(X0, X1, X2);
251
252 erf y = erf(x);
253
254 erfc
255 y = erfc(x);
256
257 exp2
258 y = exp2(x);
259
260 expm1
261 y = expm1(x);
262
263 faccessat
264 ret = faccessat(dirfd, path, amode, flags=0);
265
266 flags is the bitwise OR of zero or more of AT_EACCESS,
267 AT_SYMLINK_NOFOLLOW.
268
269 fchdir
270 ret = fchdir(dirfd);
271
272 fchmod
273 ret = fchmod(fd, mode);
274
275 fchmodat
276 ret = fchmodat(dirfd, path, mode, flags=0);
277
278 flags can be 0 or AT_SYMLINK_NOFOLLOW.
279
280 fchown
281 ret = fchown(fd, uid, gid);
282
283 fchownat
284 ret = fchownat(dirfd, path, uid, gid, flags=0);
285
286 flags can be 0 or AT_SYMLINK_NOFOLLOW.
287
288 fdatasync
289 ret = fdatasync(fd);
290
291 fdopen
292 ret = fdopen(fd, mode)
293
294 Returns a file handle associated with the file descriptor fd or
295 undef on error. mode is one of the values "r", "w", "a" with an
296 optional "+" and/or "b".
297
298 It's similar to IO::Handle::new_from_fd() with the following
299 improvements:
300
301 • It really calls fdopen(3).
302
303 • It expects POSIX mode strings (e.g. "r", not "<").
304
305 • It fails if mode is not compatible with the flags of fd.
306
307 fdopendir
308 ret = fdopendir(fd)
309
310 Returns a directory handle associated with the file descriptor fd
311 or undef on error. Usage example:
312
313 my $dh = do {
314 sysopen my $fh, '/tmp', O_RDONLY|O_DIRECTORY|O_NOFOLLOW;
315 fdopendir($fh); # or fdopendir(fileno $fh) but the former also works
316 # with handles from opendir() for which fileno does
317 # not work before Perl 5.22
318 };
319 my @files = readdir $dh; # this would fail with $fh from sysopen
320
321 fdim
322 d = fdim(double x, double y);
323
324 fegetround
325 round = fegetround();
326
327 fesetround
328 ret = fesetround(round);
329
330 ffs pos = ffs(i);
331
332 floor
333 y = floor(x);
334
335 fma r = fma(x, y, z);
336
337 fmax
338 m = fmax(x, y);
339
340 fmin
341 m = fmin(x, y);
342
343 fmod
344 m = fmod(x, y);
345
346 fnmatch
347 ret = fnmatch(pattern, string, flags);
348
349 Returns 0 if string matches pattern, FNM_NOMATCH if there is no
350 match, undef if there is an error.
351
352 flags is the bitwise OR of zero or more of FNM_NOESCAPE,
353 FNM_PATHNAME, FNM_PERIOD, FNM_FILE_NAME, FNM_LEADING_DIR,
354 FNM_CASEFOLD.
355
356 fpclassify
357 fpclassify(x);
358
359 Returns one of FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL,
360 FP_NORMAL.
361
362 fstatat
363 (dev, ino, mode, nlink, uid, gid, rdev, size, atim_sec, mtim_sec,
364 ctim_sec, blksize, blocks, atim_nsec, mtim_nsec, ctim_nsec) =
365 fstatat(dirfd, path, flags = 0);
366
367 flags is the bitwise OR of zero or more of AT_SYMLINK_NOFOLLOW,
368 AT_NO_AUTOMOUNT.
369
370 fsync
371 ret = fsync(fd);
372
373 ftruncate
374 ret = ftruncate(fd, length);
375
376 futimens
377 ret = futimens(fd, atime_sec, atime_nsec, mtime_sec, mtime_nsec);
378
379 atime_sec and mtime_sec default to 0, atime_nsec and mtime_nsec
380 default to UTIME_NOW.
381
382 getdate
383 (sec, min, hour, mday, mon, year, wday, yday, isdst) =
384 getdate(string);
385
386 getdate_err
387 getdate_err() returns the value of the getdate_err variable.
388
389 getegid
390 egid = getegid();
391
392 geteuid
393 euid = geteuid();
394
395 getgid
396 gid = getgid();
397
398 gethostid
399 hostid = gethostid();
400
401 gethostname
402 hostname = gethostname();
403
404 getitimer
405 (int_sec, int_usec, val_sec, val_usec) = getitimer(which);
406
407 which is one of ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF.
408
409 getpriority
410 prio = getpriority(which, who);
411
412 which can be one of PRIO_PROCESS, PRIO_PGRP, PRIO_USER, defaults to
413 PRIO_PROCESS.
414
415 who defaults to 0.
416
417 Returns undef on error.
418
419 getsid
420 sid = getsid(pid);
421
422 pid defaults to 0.
423
424 getuid
425 uid = getuid();
426
427 getutxent
428 (user, id, line, pid, type, sec, usec) = getutxent();
429
430 getutxent() reads a line from the current file position in the utmp
431 file.
432
433 getutxid
434 (user, id, line, pid, type, sec, usec) = getutxid(ut_type, ut_id);
435
436 getutxid() searches forward from the current file position in the
437 utmp file based upon ut_type and ut_id. If ut_type is one of
438 RUN_LVL, BOOT_TIME, NEW_TIME, or OLD_TIME, getutxid() will find the
439 first entry whose ut_type field matches ut_type. If ut_type is one
440 of INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS,
441 getutxid() will find the first entry whose ut_id field matches
442 ut_id.
443
444 getutxline
445 (user, id, line, pid, type, sec, usec) = getutxline(ut_line);
446
447 getutxline() searches forward from the current file position in the
448 utmp file. It scans entries whose ut_type is USER_PROCESS or
449 LOGIN_PROCESS and returns the first one whose ut_line field matches
450 ut_line.
451
452 hypot
453 r = hypot(x, y);
454
455 ilogb
456 y = ilogb(x);
457
458 isalpha
459 Like POSIX::isalpha() but returns 0 for the empty string.
460
461 isatty
462 ret = isatty(fd)
463
464 isblank
465 ret = isblank(charstring)
466
467 Returns 1 if charstring consists only of blank characters (i.e.
468 spaces and/or tabs). Returns 0 otherwise (also for the empty
469 string).
470
471 iscntrl
472 Like POSIX::iscntrl() but returns 0 for the empty string.
473
474 isdigit
475 Like POSIX::isdigit() but returns 0 for the empty string.
476
477 isfinite
478 isfinite(x);
479
480 isgraph
481 Like POSIX::isgraph() but returns 0 for the empty string.
482
483 isinf
484 isinf(x);
485
486 islower
487 Like POSIX::islower() but returns 0 for the empty string.
488
489 isnan
490 isnan(x);
491
492 isnormal
493 isnormal(x);
494
495 isprint
496 Like POSIX::isprint() but returns 0 for the empty string.
497
498 ispunct
499 Like POSIX::ispunct() but returns 0 for the empty string.
500
501 isspace
502 Like POSIX::isspace() but returns 0 for the empty string.
503
504 isupper
505 Like POSIX::isupper() but returns 0 for the empty string.
506
507 isxdigit
508 Like POSIX::isxdigit() but returns 0 for the empty string.
509
510 j0 y = j0(x);
511
512 j0() is the Bessel function of the first kind of order 0.
513
514 j1 y = j1(x);
515
516 j1() is the Bessel function of the first kind of order 1.
517
518 jn y = jn(n, x);
519
520 jn() is the Bessel function of the first kind of order n.
521
522 jrand48
523 (r, X0, X1, X2) = jrand48(X0, X1, X2);
524
525 killpg
526 ret = killpg(pgrp, sig);
527
528 l64a
529 s = l64a(n);
530
531 lchown
532 ret = lchown(path, uid, gid)
533
534 ldexp
535 y = ldexp(x, exp);
536
537 ldiv
538 (quot, rem) = ldiv(numer, denom);
539
540 lgamma
541 y = lgamma(x);
542
543 link
544 ret = link(path1, path2);
545
546 linkat
547 ret = linkat(fd1, path1, fd2, path2, flags=0);
548
549 flags can be 0 or AT_SYMLINK_FOLLOW.
550
551 log1p
552 y = log1p(x);
553
554 log2
555 y = log2(x);
556
557 logb
558 y = logb(x);
559
560 lrand48
561 r = lrand48();
562
563 lround
564 l = lround(x)
565
566 lstat
567 (dev, ino, mode, nlink, uid, gid, rdev, size, atim_sec, mtim_sec,
568 ctim_sec, blksize, blocks, atim_nsec, mtim_nsec, ctim_nsec) =
569 lstat(path);
570
571 mkdir
572 ret = mkdir(path, mode);
573
574 mkdirat
575 ret = mkdirat(fd, path, mode);
576
577 mkdtemp
578 name = mkdtemp(template);
579
580 mkfifo
581 ret = mkfifo(path, mode);
582
583 mkfifoat
584 ret = mkfifoat(fd, path, mode);
585
586 mknod
587 ret = mknod(path, mode, dev);
588
589 mknodat
590 ret = mknodat(fd, path, mode, dev);
591
592 mkstemp
593 (fd, name) = mkstemp(template);
594
595 mrand48
596 mrand48();
597
598 nanosleep
599 (rem_sec, rem_nsec) = nanosleep(sec, nsec);
600
601 In scalar context returns the remaining seconds as a floating point
602 number.
603
604 nearbyint
605 y = nearbyint(x);
606
607 nextafter
608 z = nextafter(x, y);
609
610 nrand48
611 r = nrand48()
612
613 open
614 ret = open(path[, flags[, mode]]);
615
616 oflag defaults to O_RDONLY, mode defaults to 0600.
617
618 openat
619 ret = openat(fd, path[, flags[, mode]]);
620
621 flags defaults to O_RDONLY, mode defaults to 0666.
622
623 If fd is numeric (i.e. a file descriptor), openat() returns a file
624 descriptor. If fd is a file or directory handle, the return value
625 is also a handle whose type depends on the file type of path: If
626 path is a directory, the return value is a directory handle,
627 otherwise it's a file handle.
628
629 To get a handle even for the special fd value AT_FDCWD (which is
630 numeric), you can pass a reference to that value instead, i.e.
631 "openat(\AT_FDCWD, ...)".
632
633 Returns undef on error.
634
635 openat2
636 ret = openat2(fd, path, how)
637
638 The openat2() system call is an extension of openat() and provides
639 a superset of its functionality. It is Linux-specific and thus not
640 part of POSIX, but we include it anyway.
641
642 The how parameter is a hash reference corresponding to the struct
643 open_how. It currently supports the keys flags, mode and resolve.
644 Missing keys are treated as having a zero value.
645
646 Example:
647
648 my $fh = openat2(
649 \AT_FDCWD, '/foobar',
650 {flags => O_RDWR|O_CREAT, mode => 0600, resolve => RESOLVE_IN_ROOT}
651 );
652
653 Note that, unlike open() or openat(), openat2() is very picky about
654 flags and mode. See the manpage for details.
655
656 Returns undef on error.
657
658 posix_fadvise
659 ret = posix_fadvise(fd, offset, len, advice);
660
661 advice is one of the "POSIX_FADV_" constants.
662
663 Returns undef on error
664
665 posix_fallocate
666 ret = posix_fallocate(fd, offset, len);
667
668 pread
669 bytes_read = pread(fd, buf, count, [offset, buf_offset]);
670
671 pread() reads count bytes (not characters) of data from the file
672 descriptor fd at file offset offset into the scalar buf without
673 changing the file offset. buf will be enlarged automatically if
674 necessary.
675
676 offset and buf_offset are set to 0 if omitted or undef.
677
678 pread() treats buf just like sysread() does: buf_offset may be
679 specified to place the read data at that position in buf. If
680 buf_offset is past the end of buf, buf will be padded with zeros
681 before appending the data. If buf_offset is negative, it is counted
682 from the end of the string. buf will be grown or shrunk so that the
683 last byte actually read is the last byte of buf after the read.
684
685 Returns the number of bytes read, 0 at EOF, undef on error.
686
687 preadv
688 bytes_read = preadv(fd, buffers, sizes, [offset])
689
690 preadv() behaves like readv() but adds an optional offset argument,
691 which specifies the file position at which the data is to be read.
692 offset is set to 0 if omitted or undef.
693
694 The file offset is not changed by this system call. The file
695 referred to by fd must be capable of seeking.
696
697 ptsname
698 name = ptsname(fd);
699
700 pwrite
701 bytes_written = pwrite(fd, buf, [count, offset, buf_offset]);
702
703 pwrite() writes count bytes of data from the scalar buf to the file
704 descriptor fd at file offset offset without changing the file
705 offset. The file referenced by fd must be capable of seeking.
706
707 If count is omitted or undef, everything from buf_offset up to the
708 end of buf is written.
709
710 buf_offset may be specified to write data from that position in
711 buf. If buf_offset is negative it is counted from the end of the
712 string.
713
714 offset and buf_offset are set to 0 if omitted or undef.
715
716 Returns the number of bytes written, undef on error.
717
718 On Linux, if a file is opened with O_APPEND, pwrite() appends data
719 to the end of the file, regardless of the value of offset (in
720 violation of POSIX).
721
722 pwritev
723 bytes_written = pwritev(fd, buffers, [offset])
724
725 pwritev() behaves like writev() but adds an optional offset
726 argument, which specifies the file position at which the data is to
727 be written. offset is set to 0 if omitted or undef.
728
729 The file offset is not changed by this system call. The file
730 referred to by fd must be capable of seeking.
731
732 random
733 r = random();
734
735 read
736 bytes_read = read(fd, buf, count);
737
738 Like POSIX::read() but returns 0 at EOF instead of "0 but true".
739
740 readv
741 bytes_read = readv(fd, buffers, sizes);
742
743 Example:
744
745 sysopen my $fh, '/tmp/foobar', O_RDWR|O_CREAT|O_TRUNC;
746 pwrite($fh, 'foobar', 6, 0);
747 readv($fh, my @buf, [4, 0, 4, 4]);
748 # -> @buf is ('foob', '', 'ar')
749
750 readv() reads from the file descriptor fd into buffers as many
751 strings as there are elements in sizes. buffers must be a variable
752 holding an array or an array reference. sizes must be an array
753 reference.
754
755 sizes is expected to hold unsigned integers that specify how many
756 bytes are to be read into each buffer. A byte count of 0 or undef
757 creates an empty string. sizes is processed in array order.
758
759 buffers will be extended if necessary, but it will never be shrunk.
760 If buffers is not empty, any existing elements are replaced as long
761 as sufficient data was read from fd.
762
763 If the total byte count of sizes exceeds the number of bytes
764 actually read from fd, there may be one partly filled buffer and
765 the rest of sizes is skipped, so you may end up with less strings
766 in buffers than there are elements in sizes.
767
768 readv() returns the number of bytes read (which may be less than
769 the total bytes in sizes) or undef on error.
770
771 readlink
772 name = readlink(path);
773
774 Returns undef on error.
775
776 readlinkat
777 name = readlinkat(dirfd, path);
778
779 Returns undef on error.
780
781 realpath
782 resolved_path = realpath(path);
783
784 Calls the actual C library fuction realpath() and relies on it to
785 be able to allocate memory for the resolved path automatically (as
786 required by POSIX-2008).
787
788 Returns undef on error.
789
790 remainder
791 r = remainder(x, y);
792
793 remove
794 ret = remove(path);
795
796 Calls the actual C library function remove().
797
798 Note that POSIX::remove() fails if path is a symlink to a directory
799 because someone "couldn't read the plans right and did a piss-poor
800 job of putting it together" as "(-d $_[0]) ? CORE::rmdir($_[0]) :
801 CORE::unlink($_[0])". Quote from Armageddon.
802
803 This could be fixed like this: "unlink $_[0] or ($!{EISDIR} ||
804 $!{EPERM} ? rmdir $_[0] : undef)", or by using the library call
805 right away.
806
807 rename
808 ret = rename(old, new);
809
810 renameat
811 ret = renameat(olddirfd, oldpath, newdirfd, newpath);
812
813 round
814 r = round(x);
815
816 scalbn
817 y = scalbn(x, n);
818
819 seed48
820 (old_seed1, old_seed2, old_seed3) = seed48(seed1, seed2, seed3);
821
822 setegid
823 ret = setegid(gid);
824
825 seteuid
826 ret = seteuid(uid);
827
828 setgid
829 ret = setgid(gid);
830
831 setitimer
832 (old_int_sec, old_int_usec, old_val_sec, old_val_usec) =
833 setitimer(which, int_sec, int_usec, val_sec, val_usec);
834
835 which is one of ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF.
836
837 setpriority
838 ret = setpriority(value, which, who);
839
840 which can be one of PRIO_PROCESS, PRIO_PGRP, PRIO_USER, defaults to
841 PRIO_PROCESS.
842
843 Returns true on success, undef on error.
844
845 who defaults to 0.
846
847 setregid
848 ret = setregid(rgid, egid);
849
850 setreuid
851 ret = setreuid(ruid, euid);
852
853 setuid
854 ret = setuid(uid);
855
856 setutxent
857 setutxent();
858
859 sighold
860 ret = sighold(sig);
861
862 sigignore
863 ret = sigignore(sig);
864
865 signbit
866 b = signbit(x);
867
868 sigpause
869 sigpause(sig);
870
871 sigrelse
872 ret = sigrelse(sig);
873
874 sinh
875 y = sinh(x);
876
877 srand48
878 srand48(seedval);
879
880 srandom
881 srandom(seed);
882
883 stat
884 (dev, ino, mode, nlink, uid, gid, rdev, size, atim_sec, mtim_sec,
885 ctim_sec, blksize, blocks, atim_nsec, mtim_nsec, ctim_nsec) =
886 stat(path);
887
888 strptime
889 (sec, min, hour, mday, mon, year, wday, yday, isdst) = strptime(s,
890 format[, sec, min, hour, mday, mon, year, wday, yday, isdst]);
891
892 strptime() converts the string s into a broken-down time according
893 to the format string format. The time fields may optionally be
894 initialized in whole or in part and will be returned as initialized
895 if they are not affected by the format string. Unprocessed
896 uninitialized or undef fields are returned as undef.
897
898 Returns an empty list on error.
899
900 In scalar context returns the index of the first byte in s that was
901 not processed or the byte length of s if the whole string was
902 consumed or undef on error.
903
904 As strptime() acts on null-terminated strings, strings containing
905 NUL bytes will only be processed up to the first NUL byte.
906
907 symlink
908 symlink(old, new);
909
910 symlinkat
911 ret = symlinkat(old, dirfd, new);
912
913 sync
914 sync();
915
916 tan y = tan(x);
917
918 tanh
919 y = tanh(x);
920
921 tgamma
922 y = tgamma(x);
923
924 timer_create
925 timerid = timer_create(clockid, signal);
926
927 Returns undef on error.
928
929 timer_delete
930 timer_delete(timerid);
931
932 Returns '0 but true' on success, undef on error.
933
934 timer_getoverrun
935 count = timer_getoverrun(timerid);
936
937 Returns undef on error.
938
939 timer_gettime
940 (interval_sec, interval_nsec, initial_sec, initial_nsec) =
941 timer_gettime(timerid);
942
943 Returns an empty list on error.
944
945 timer_settime
946 (old_int_sec, old_int_nsec, old_init_sec, old_init_nsec) =
947 timer_settime(timerid, flags, int_sec, int_nsec, [init_sec,
948 init_nsec]);
949
950 flags may be 0 or "TIMER_ABSTIME". If the init values are omitted,
951 they are set to the int values.
952
953 truncate
954 ret = truncate(path, length);
955
956 trunc
957 y = trunc(x);
958
959 unlinkat
960 ret = unlinkat(dirfd, path, flags=0);
961
962 flags can be 0 or AT_REMOVEDIR.
963
964 unlink
965 ret = unlink(path);
966
967 Calls the actual C library function unlink().
968
969 Note that POSIX::unlink() calls CORE::unlink(), which, unless you
970 start Perl with "-U", a) is prone to time-of-check/time-of-use race
971 conditions due to an additional lstat(), and b) blindly fails with
972 EISDIR for directories (due to said lstat()), ignoring that some
973 OSes use EPERM in this case (as required by POSIX).
974
975 utimensat
976 ret = utimensat(dirfd, path, flags, atime_sec, atime_nsec,
977 mtime_sec, mtime_nsec);
978
979 flags can be 0 or AT_SYMLINK_NOFOLLOW, defaults to 0.
980
981 atime_sec and mtime_sec default to 0. atime_nsec and mtime_nsec
982 default to UTIME_NOW.
983
984 write
985 bytes_written = write(fd, buf[, count]);
986
987 Like POSIX::write() but returns 0 instead of "0 but true" if 0
988 bytes were written, and never writes more bytes than buf contains
989 even if count exceeds the length of buf.
990
991 If count is omitted or undef, it defaults to the length of buf.
992
993 writev
994 bytes_written = writev(fd, buffers);
995
996 writev() writes multiple buffers from buffers to the file
997 associated with the file descriptor fd. buffers must be an array
998 reference. The buffers are processed in array order. Undefined or
999 empty elements are skipped.
1000
1001 Returns the number of bytes written or undef on error.
1002
1003 y0 y = y0(x);
1004
1005 y0() is the Bessel function of the second kind of order 0.
1006
1007 y1 y = y1(x);
1008
1009 y1() is the Bessel function of the second kind of order 1.
1010
1011 yn y = yn(n, x);
1012
1013 yn() is the Bessel function of the second kind of order n.
1014
1016 This module does not export anything by default. The following export
1017 tags are available:
1018
1019 :at All *at() functions like openat() and all AT_/RESOLVE_ constants
1020 :id All get/set*id() functions like getuid() etc.
1021 :is All is* functions like isdigit() etc.
1022 :rw read(), readv(), write(), writev()
1023 :prw pread(), preadv(), pwrite(), pwritev()
1024 :clock All clock* functions and all CLOCK* constants
1025 :fcntl All F_, FD_, O_, POSIX_FADV_ and SEEK_ constants (for AT_ use :at)
1026 :fnm C<fnmatch()> and all FNM_ constants
1027 :time_h All CLOCK_ and TIMER_ constants
1028 :timer All timer_ functions and TIMER_ constants
1029
1031 "AT_EACCESS" "AT_EMPTY_PATH" "AT_FDCWD" "AT_NO_AUTOMOUNT"
1032 "AT_REMOVEDIR" "AT_SYMLINK_FOLLOW" "AT_SYMLINK_NOFOLLOW"
1033 "RESOLVE_BENEATH" "RESOLVE_IN_ROOT" "RESOLVE_NO_MAGICLINKS"
1034 "RESOLVE_NO_SYMLINKS" "RESOLVE_NO_XDEV" "RESOLVE_CACHED"
1035
1036 "BOOT_TIME" "NEW_TIME" "OLD_TIME" "DEAD_PROCESS" "INIT_PROCESS"
1037 "LOGIN_PROCESS" "USER_PROCESS" "RUN_LVL"
1038
1039 "CLOCK_BOOTTIME" "CLOCK_HIGHRES" "CLOCK_MONOTONIC"
1040 "CLOCK_MONOTONIC_COARSE" "CLOCK_MONOTONIC_FAST"
1041 "CLOCK_MONOTONIC_PRECISE" "CLOCK_MONOTONIC_RAW"
1042 "CLOCK_PROCESS_CPUTIME_ID" "CLOCK_REALTIME" "CLOCK_REALTIME_COARSE"
1043 "CLOCK_REALTIME_FAST" "CLOCK_REALTIME_PRECISE" "CLOCK_SOFTTIME"
1044 "CLOCK_THREAD_CPUTIME_ID" "CLOCK_UPTIME" "CLOCK_UPTIME_FAST"
1045 "CLOCK_UPTIME_PRECISE"
1046
1047 "_CS_GNU_LIBC_VERSION" "_CS_GNU_LIBPTHREAD_VERSION" "_CS_PATH"
1048
1049 "F_DUPFD" "F_DUPFD_CLOEXEC" "F_GETFD" "F_SETFD" "F_GETFL" "F_SETFL"
1050 "F_GETLK" "F_SETLK" "F_SETLKW" "F_GETOWN" "F_SETOWN" "F_RDLCK"
1051 "F_UNLCK" "F_WRLCK"
1052
1053 "FD_CLOEXEC"
1054
1055 "FNM_CASEFOLD" "FNM_FILE_NAME" "FNM_LEADING_DIR" "FNM_NOESCAPE"
1056 "FNM_NOMATCH" "FNM_PATHNAME" "FNM_PERIOD"
1057
1058 "FP_INFINITE" "FP_NAN" "FP_NORMAL" "FP_SUBNORMAL" "FP_ZERO"
1059
1060 "TIMER_ABSTIME" "ITIMER_PROF" "ITIMER_REAL" "ITIMER_VIRTUAL"
1061
1062 "O_ACCMODE" "O_APPEND" "O_CLOEXEC" "O_CREAT" "O_DIRECTORY" "O_DSYNC"
1063 "O_EXEC" "O_NOCTTY" "O_NOFOLLOW" "O_NONBLOCK" "O_RDONLY" "O_RDWR"
1064 "O_RSYNC" "O_SEARCH" "O_SYNC" "O_TMPFILE" "O_TRUNC" "O_TTY_INIT"
1065 "O_WRONLY"
1066
1067 "POSIX_FADV_NORMAL" "POSIX_FADV_SEQUENTIAL" "POSIX_FADV_RANDOM"
1068 "POSIX_FADV_NOREUSE" "POSIX_FADV_WILLNEED" "POSIX_FADV_DONTNEED"
1069
1070 "RTLD_GLOBAL" "RTLD_LAZY" "RTLD_LOCAL" "RTLD_NOW"
1071
1072 "SEEK_SET" "SEEK_CUR" "SEEK_END"
1073
1074 "UTIME_NOW" "UTIME_OMIT"
1075
1077 preadv(), pwritev() and openat2() are not part of POSIX. They are
1078 included anyway.
1079
1080 fstatat(), lstat() and stat() do not set the special underscore
1081 filehandle (_) (mostly because I have no clue how that works).
1082
1083 open(), openat() and openat2() do not set the O_CLOEXEC flag
1084 automatically. You have to take care of that yourself if needed.
1085
1087 Initially hacked together by Carsten Gaebler.
1088
1090 This library is free software. You can redistribute and/or modify it
1091 under the terms of the Do What The Fuck You Want To Public License,
1092 Version 2, as published by Sam Hocevar. See the COPYING file or
1093 http://www.wtfpl.net/ for more details.
1094
1095
1096
1097perl v5.36.1 2023-06-02 POSIX::2008(3)