POSIX::2008(3) Perl interface to POSIX.1-2008

SYNOPSIS


use POSIX qw(:fcntl_h);
use POSIX::2008;
my $dd = POSIX::2008::open('/tmp/');
my $fd = POSIX::2008::openat($dd, 'foobar', O_RDWR|O_CREAT);
POSIX::2008::pwrite($fd, 'fuckyounsa', 50);

DESCRIPTION

POSIX::2008 contains many of the interfaces specified by POSIX.1-2008 that the core POSIX module withholds, implements in Perl or fucked up.

This module is provided ``as is'' unless someone volunteers to maintain it.

FUNCTIONS

a64l
n = a64l(s);
abort
abort();
abs
ui = abs(i);
acos
y = acos(x);
acosh
y = acosh(x);
alarm
remaining_sec = alarm(sec);
asin
y = asin(x);
asinh
y = asinh(x);
atan2
z = atan2(y, x);
atan
y = atan(x);
atanh
y = atanh(x);
atof
f = atof(s);
atoi
i = atoi(s);
atol
l = atol(s);
basename
s = basename(path);
cabs
r = cabs(re, im);
cacos
(re, im) = cacos(re, im);
cacosh
(re, im) = cacosh(re, im);
carg
phi = carg(re, im);
casinh
(re, im) = casinh(re, im);
catan
(re, im) = catan(re, im);
catanh
(re, im) = catanh(re, im);
catclose
ret = catclose(catd);
catgets
s = catgets(catd, set_id, msg_id, dflt_string);
catopen
catd = catopen(name, oflag);
cbrt
y = cbrt(x);
ccos
(re, im) = ccos(re, im);
ccosh
(re, im) = ccosh(re, im);
ceil
y = ceil(x);
cexp
(re, im) = cexp(re, im);
chdir
ret = chdir(path);
chmod
ret = chmod(path, mode);
chown
ret = chown(path, uid, gid);
cimag
im = cimag(re, im);
clock_getcpuclockid
clock_id = clock_getcpuclockid(pid);

pid defaults to $$. Returns undef on error.

clock_getres
(sec, nsec) = clock_getres(clock_id);

clock_id defaults to CLOCK_REALTIME. Returns empty list on error.

clock_gettime
(sec, nsec) = clock_gettime(clock_id);

clock_id defaults to CLOCK_REALTIME. Returns empty list on error.

clock_nanosleep
(rem_sec, rem_nsec) = clock_nanosleep(clock_id, flags, sec, nsec);

In scalar context returns the remaining seconds as a floating point number.

clock_settime
ret = clock_settime(clock_id, sec, nsec);
clog
(re, im) = clog(re, im);
confstr
s = confstr(name);

name is one of the _CS_ integer constants.

conj
(re, im) = conj(re, im);
copysign
xs = copysign(x, y);
cos
y = cos(x);
cosh
y = cosh(x);
cpow
(re, im) = cpow(re_x, im_x, re_y, im_y);
cproj
(re, im) = cproj(re, im);
creal
re = creal(re, im);
csin
(re, im) = csin(re, im);
csinh
(re, im) = csinh(re, im);
csqrt
(re, im) = csqrt(re, im);
ctan
(re, im) = ctan(re, im);
ctanh
(re, im) = ctanh(re, im);
dirname
name = dirname(path);
div
(quot, rem) = div(numer, denom);
dlclose
dlclose(dlhandle);
dlerror
dlerror();
dlopen
dlhandle = dlopen(file, mode);
dlsym
addr = dlsym(dlhandle, name);
drand48
r = drand48();
endutxent
endutxent();
erand48
(r, X0, X1, X2) = erand48(X0, X1, X2);
erf
y = erf(x);
erfc
y = erfc(x);
exp2
y = exp2(x);
expm1
y = expm1(x);
faccessat
ret = faccessat(dirfd, path, amode, flags);

flags is the bitwise OR of zero or more of AT_EACCESS, AT_SYMLINK_NOFOLLOW.

fchdir
ret = fchdir(dirfd);
fchmod
ret = fchmod(fd, mode);
fchmodat
ret = fchmodat(dirfd, path, mode, flags);

flags can be 0 or AT_SYMLINK_NOFOLLOW.

fchown
ret = fchown(fd, uid, gid);
fchownat
ret = fchownat(dirfd, path, uid, gid, flags);

flags can be 0 or AT_SYMLINK_NOFOLLOW.

fdatasync
ret = fdatasync(fd);
fdim
d = fdim(double x, double y);
fegetround
round = fegetround();
fesetround
ret = fesetround(round);
ffs
pos = ffs(i);
floor
y = floor(x);
fma
r = fma(x, y, z);
fmax
m = fmax(x, y);
fmin
m = fmin(x, y);
fmod
m = fmod(x, y);
fnmatch
ret = fnmatch(pattern, string, flags);

Returns 0 if string matches pattern, FNM_NOMATCH if there is no match, undef if there is an error.

flags is the bitwise OR of zero or more of FNM_NOESCAPE, FNM_PATHNAME, FNM_PERIOD, FNM_FILE_NAME, FNM_LEADING_DIR, FNM_CASEFOLD.

fpclassify
fpclassify(x);

Returns one of FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL.

fstatat
(dev, ino, mode, nlink, uid, gid, rdev, size, atim_sec, mtim_sec, ctim_sec, blksize, blocks, atim_nsec, mtim_nsec, ctim_nsec) = fstatat(dirfd, path, flags);

flags is the bitwise OR of zero or more of AT_SYMLINK_NOFOLLOW, AT_NO_AUTOMOUNT.

fsync
ret = fsync(fd);
ftruncate
ret = ftruncate(fd, length);
futimens
ret = futimens(fd, atime_sec, atime_nsec, mtime_sec, mtime_nsec);

atime_sec and mtime_sec default to 0, atime_nsec and mtime_nsec default to UTIME_NOW.

getdate
(sec, min, hour, mday, mon, year, wday, yday, isdst) = getdate(string);
getdate_err
getdate_err() returns the value of the getdate_err variable.
getegid
egid = getegid();
geteuid
euid = geteuid();
getgid
gid = getgid();
gethostid
hostid = gethostid();
gethostname
hostname = gethostname();
getitimer
(int_sec, int_usec, val_sec, val_usec) = getitimer(which);

which is one of ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF.

getpriority
prio = getpriority(which, who);

which can be one of PRIO_PROCESS, PRIO_PGRP, PRIO_USER, defaults to PRIO_PROCESS.

who defaults to 0.

Returns undef on error.

getsid
sid = getsid(pid);

pid defaults to 0.

getuid
uid = getuid();
getutxent
(user, id, line, pid, type, sec, usec) = getutxent();

getutxent() reads a line from the current file position in the utmp file.

getutxid
(user, id, line, pid, type, sec, usec) = getutxid(ut_type, ut_id);

getutxid() searches forward from the current file position in the utmp file based upon ut_type and ut_id. If ut_type is one of RUN_LVL, BOOT_TIME, NEW_TIME, or OLD_TIME, getutxid() will find the first entry whose ut_type field matches ut_type. If ut_type is one of INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS, getutxid() will find the first entry whose ut_id field matches ut_id.

getutxline
(user, id, line, pid, type, sec, usec) = getutxline(ut_line);

getutxline() searches forward from the current file position in the utmp file. It scans entries whose ut_type is USER_PROCESS or LOGIN_PROCESS and returns the first one whose ut_line field matches ut_line.

hypot
r = hypot(x, y);
ilogb
y = ilogb(x);
isalpha
Like POSIX::isalpha() but returns 0 for the empty string.
iscntrl
Like POSIX::iscntrl() but returns 0 for the empty string.
isdigit
Like POSIX::isdigit() but returns 0 for the empty string.
isfinite
isfinite(x);
isgraph
Like POSIX::isgraph() but returns 0 for the empty string.
isinf
isinf(x);
islower
Like POSIX::islower() but returns 0 for the empty string.
isnan
isnan(x);
isnormal
isnormal(x);
isprint
Like POSIX::isprint() but returns 0 for the empty string.
ispunct
Like POSIX::ispunct() but returns 0 for the empty string.
isspace
Like POSIX::isspace() but returns 0 for the empty string.
isupper
Like POSIX::isupper() but returns 0 for the empty string.
isxdigit
Like POSIX::isxdigit() but returns 0 for the empty string.
j0
y = j0(x);

j0() is the Bessel function of the first kind of order 0.

j1
y = j1(x);

j1() is the Bessel function of the first kind of order 1.

jn
y = jn(n, x);

jn() is the Bessel function of the first kind of order n.

jrand48
(r, X0, X1, X2) = jrand48(X0, X1, X2);
killpg
ret = killpg(pgrp, sig);
l64a
s = l64a(n);
ldexp
y = ldexp(x, exp);
ldiv
(quot, rem) = ldiv(numer, denom);
lgamma
y = lgamma(x);
link
ret = link(path1, path2);
linkat
ret = linkat(fd1, path1, fd2, path2, flags);

flags can be 0 or AT_SYMLINK_FOLLOW.

log1p
y = log1p(x);
log2
y = log2(x);
logb
y = logb(x);
lrand48
r = lrand48();
lstat
ret = lstat(path);
mkdir
ret = mkdir(path, mode);
mkdirat
ret = mkdirat(fd, path, mode);
mkdtemp
name = mkdtemp(template);
mkfifo
ret = mkfifo(path, mode);
mkfifoat
ret = mkfifoat(fd, path, mode);
mknod
ret = mknod(path, mode, dev);
mknodat
ret = mknodat(fd, path, mode, dev);
mkstemp
(fd, name) = mkstemp(template);
mrand48
mrand48();
nanosleep
(rem_sec, rem_nsec) = nanosleep(sec, nsec);

In scalar context returns the remaining seconds as a floating point number.

nearbyint
y = nearbyint(x);
nextafter
z = nextafter(x, y);
nrand48
r = nrand48()
openat
ret = openat(fd, path, oflag, mode);

oflag defaults to O_RDONLY, mode defaults to 0666.

open
ret = open(path, oflag, mode);

oflag defaults to O_RDONLY, mode defaults to 0666.

pread
bytes_read = pread(fd, buf, file_offset, nbytes[, buf_offset]);

pread() reads nbytes of data from the file descriptor fd at file offset offset into the scalar buf without changing the file offset. buf will be enlarged automatically if necessary.

buf_offset may be specified to store the data at that position in buf. Defaults to 0. If buf_offset is past the end of buf, buf will be padded with zeros before appending the data. If buf_offset is negative it is counted from the end of the string.

Returns the number of bytes read, 0 at EOF, undef on error.

Note that pread() deals with bytes not characters.

ptsname
name = ptsname(fd);
pwrite
bytes_written = pwrite(fd, buf, offset[, nbytes, buf_offset]);

pwrite() writes data from the scalar buf to the file descriptor fd at file offset offset without changing the file offset. The file referenced by fd must be capable of seeking.

nbytes may be specified to write only that much bytes. If not specified or undef, everything from buf_offset up to the end of buf is written.

buf_offset may be specified to write data from that position in buf. Defaults to 0. If buf_offset is negative it is counted from the end of the string.

Returns the number of bytes written, undef on error.

Note that pwrite() deals with bytes not characters.

random
r = random();
read
ret = read(fd, buf, nbytes);

Like POSIX::read() but returns 0 at EOF instead of ``0 but true''.

readlink
name = readlink(path);

Returns undef on error.

readlinkat
name = readlinkat(dirfd, path);

Returns undef on error.

remainder
r = remainder(x, y);
remove
ret = remove(path);

Like POSIX::remove() but calls the C function instead of doing it in Perl.

rename
ret = rename(old, new);
renameat
ret = renameat(olddirfd, oldpath, newdirfd, newpath);
round
r = round(x);
scalbn
y = scalbn(x, n);
seed48
(old_seed1, old_seed2, old_seed3) = seed48(seed1, seed2, seed3);
setegid
ret = setegid(gid);
seteuid
ret = seteuid(uid);
setgid
ret = setgid(gid);
setitimer
(old_int_sec, old_int_usec, old_val_sec, old_val_usec) = setitimer(which, int_sec, int_usec, val_sec, val_usec);

which is one of ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF.

setpriority
ret = setpriority(value, which, who);

which can be one of PRIO_PROCESS, PRIO_PGRP, PRIO_USER, defaults to PRIO_PROCESS.

Returns true on success, undef on error.

who defaults to 0.

setregid
ret = setregid(rgid, egid);
setreuid
ret = setreuid(ruid, euid);
setuid
ret = setuid(uid);
setutxent
setutxent();
sighold
ret = sighold(sig);
sigignore
ret = sigignore(sig);
signbit
b = signbit(x);
sigpause
sigpause(sig);
sigrelse
ret = sigrelse(sig);
sinh
y = sinh(x);
srand48
srand48(seedval);
srandom
srandom(seed);
stat
(dev, ino, mode, nlink, uid, gid, rdev, size, atim_sec, mtim_sec, ctim_sec, blksize, blocks, atim_nsec, mtim_nsec, ctim_nsec) = stat(path);
strptime
(sec, min, hour, mday, mon, year, wday, yday, isdst) = strptime(s, format[, sec, min, hour, mday, mon, year, wday, yday, isdst]);

strptime() converts the string s into a broken-down time according to the format string format. The time fields may optionally be initialized in whole or in part and will be returned as initialized if they are not affected by the format string. Unprocessed uninitialized or undef fields are returned as undef.

Returns an empty list on error.

In scalar context returns the index of the first byte in s that was not processed or the byte length of s if the whole string was consumed or undef on error.

As strptime() acts on null-terminated strings, strings containing NUL bytes will only be processed up to the first NUL byte.

symlink
symlink(old, new);
symlinkat
ret = symlinkat(old, dirfd, new);
sync
sync();
tan
y = tan(x);
tanh
y = tanh(x);
tgamma
y = tgamma(x);
truncate
ret = truncate(path, length);
trunc
y = trunc(x);
unlinkat
ret = unlinkat(dirfd, path, flags);

flags can be 0 or AT_REMOVEDIR.

unlink
ret = unlink(path);
utimensat
ret = utimensat(dirfd, path, flags, atime_sec, atime_nsec, mtime_sec, mtime_nsec);

flags can be 0 or AT_SYMLINK_NOFOLLOW, defaults to 0.

atime_sec and mtime_sec default to 0. atime_nsec and mtime_nsec default to UTIME_NOW.

y0
y = y0(x);

y0() is the Bessel function of the second kind of order 0.

y1
y = y1(x);

y1() is the Bessel function of the second kind of order 1.

yn
y = yn(n, x);

yn() is the Bessel function of the second kind of order n.

CONSTANTS

AT_EACCESS AT_EMPTY_PATH AT_FDCWD AT_NO_AUTOMOUNT AT_REMOVEDIR AT_SYMLINK_FOLLOW AT_SYMLINK_NOFOLLOW BOOT_TIME CLOCK_MONOTONIC CLOCK_MONOTONIC_RAW CLOCK_PROCESS_CPUTIME_ID CLOCK_REALTIME CLOCK_THREAD_CPUTIME_ID _CS_GNU_LIBC_VERSION _CS_GNU_LIBPTHREAD_VERSION _CS_PATH DEAD_PROCESS FNM_CASEFOLD FNM_FILE_NAME FNM_LEADING_DIR FNM_NOESCAPE FNM_NOMATCH FNM_PATHNAME FNM_PERIOD FP_INFINITE FP_NAN FP_NORMAL FP_SUBNORMAL FP_ZERO INIT_PROCESS ITIMER_PROF ITIMER_REAL ITIMER_VIRTUAL LOGIN_PROCESS NEW_TIME O_CLOEXEC O_DIRECTORY O_EXEC OLD_TIME O_NOFOLLOW O_RSYNC O_SEARCH O_SYNC O_TMPFILE O_TTY_INIT RTLD_GLOBAL RTLD_LAZY RTLD_LOCAL RTLD_NOW RUN_LVL TIMER_ABSTIME USER_PROCESS UTIME_NOW UTIME_OMIT

AUTHOR

Initially hacked together by Carsten Gaebler.

LICENCE

This library is free software. You can redistribute and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file or http://www.wtfpl.net/ for more details.