home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


8.123 POSIX

Provides access to standard POSIX 1003.1 identifiers: functions, classes, and constants. Can be use d to import one or multiple symbols:

use POSIX;                        # import all symbols
use POSIX qw(setsid);             # import one symbol
use POSIX qw(:errno_h :fcntl_h);  # import sets of symbols
Functions listed as C-specific are not implemented.

_exit Identical to C function _exit(2)
abort Identical to C function abort(3)
abs Identical to Perl's abs function
access

Determines accessibility of a file; returns undef on failure

acos

Identical to C function acos(3)

alarm

Identical to Perl's alarm function

asctime

Identical to C function asctime(3)

asin

Identical to C function asin(3)

assert

Similar to C macro assert(3)

atan

Identical to C function atan(3)

atan2

Identical to Perl's atan2 function

atexit

C-specific; use END {}

atof

C-specific

atoi C-specific
atol C-specific
bsearch Not supplied
calloc C-specific
ceil

Identical to C function ceil(3)

chdir

Identical to Perl's chdir function

chmod

Identical to Perl's chmod function

chown

Identical to Perl's chown function

clearerr

Uses method FileHandle::clearerr

clock

Identical to C function clock(3)

close

Closes a file; returns undef on failure

closedir

Identical to Perl's closedir function

cos

Identical to Perl's cos function

cosh

Identical to C function cosh(3)

creat

Creates a new file

ctermid

Generates path name for the controlling terminal

ctime

Identical to C function ctime(3)

cuserid

Gets user's login name

difftime

Identical to C function difftime(3)

div C-specific
dup

Similar to C function dup(2) ; returns undef on failure

dup2

Similar to C function dup2(2) ; returns undef on failure

errno

Returns the value of errno

execl

C-specific; use Perl's exec

execle

C-specific; use Perl's exec

execlp

C-specific; use Perl's exec

execv

C-specific; use Perl's exec

execve

C-specific; use Perl's exec

execvp

C-specific; use Perl's exec

exit

Identical to Perl's exit function

exp

Identical to Perl's exp function

fabs

Identical to Perl's abs function

fclose

Uses method FileHandle::close

fcntl

Identical to Perl's fcntl function

fdopen

Uses method FileHandle::new_from_fd

feof

Uses method FileHandle::eof

ferror

Uses method FileHandle::error

fflush

Uses method FileHandle::flush

fgetc

Uses method FileHandle::getc

fgetpos

Uses method FileHandle::getpos

fgets

Uses method FileHandle::gets

fileno

Uses method FileHandle::fileno

floor

Identical to C function floor(3)

fmod

Identical to C function fmod(3)

fopen

Uses method FileHandle::open

fork

Identical to Perl's fork function

fpathconf

Returns value of a configurable limit on a file or directory, or undef on failure

fprintf

C-specific; use Perl's printf function

fputc

C-specific; use Perl's print function

fputs

C-specific; use Perl's print function

fread

C-specific; use Perl's read function

free C-specific
freopen

C-specific; use Perl's open function

frexp

Returns mantissa and exponent of a floating-point number

fscanf

C-specific; use <> and regular expressions

fseek

Uses method FileHandle::seek

fsetpos

Uses method FileHandle::setpos

fstat

Gets file status

ftell

Uses method FileHandle::tell

fwrite

C-specific; use Perl's print function

getc

Identical to Perl's etc function

getchar

Returns one character from STDIN

getcwd

Returns name of current working directory

getegid

Returns effective group ID ( gid )

getenv

Returns value of the specified environment variable

geteuid

Returns the effective user ID ( uid )

getgid

Returns the user's real group ID ( gid )

getgrgid

Identical to Perl's getgrgid function

getgrnam

Identical to Perl's getgrnam function

getgroups

Returns ids of the user's supplementary groups

getlogin

Identical to Perl's getlogin function

getpgrp

Identical to Perl's getpgrp function

getpid

Returns ID of the process ( pid )

getppid

Identical to Perl's getppid function

getpwnam

Identical to Perl's getpwnam function

getpwuid

Identical to Perl's getpwuid function

gets

Returns one line from STDIN

getuid

Returns user's ID ( uid )

gmtime

Identical to Perl's gmtime function

isalnum

Identical to C function, but can apply to one character or a whole string

isalpha

Identical to C function, but can apply to one character or a whole string

isatty

Returns Boolean indicating whether the specified filehandle is connected to a TTY

iscntrl

Identical to C function, but can apply to one character or a whole string

isdigit

Identical to C function, but can apply to one character or a whole string

isgraph

Identical to C function, but can apply to one character or a whole string

islower

Identical to C function, but can apply to one character or a whole string

isprint

Identical to C function, but can apply to one character or a whole string

ispunct

Identical to C function, but can apply to one character or a whole string

isspace

Identical to C function, but can apply to one character or a whole string

isupper

Identical to C function, but can apply to one character or a whole string

isxdigit

Identical to C function, but can apply to one character or a whole string

kill

Identical to Perl's kill function

labs

C-specific; use Perl's abs function

ldexp

Identical to C function ldexp(3)

ldiv

C-specific; use division operator ( / ) and Perl's int function

link

Identical to Perl's link function

localeconv

Gets numeric formatting information. Returns reference to a hash containing the current locale formatting values.

localtime

Identical to Perl's localtime function

log

Identical to Perl's log function

log10

Identical to C function log10(3)

longjmp

C-specific; use Perl's die function

lseek

Moves the read/write file pointer; returns undef on failure

malloc

C-specific

mblen

Identical to C function mblen(3)

mbstowcs

Identical to C function mbstowcs(3)

mbtowc

Identical to C function mbtowc(3)

memchr

C-specific; use Perl's index

memcmp

C-specific; use eq

memcpy

C-specific; use =

memmove

C-specific; use =

memset

C-specific; use x

mkdir

Identical to Perl's mkdir function

mkfifo

Similar to C function mkfifo(2) ; returns undef on failure

mktime

Converts date/time information to a calendar time; returns undef on failure

modf

Returns integral and fractional parts of a floating-point number

nice

Similar to C function nice(3) ; returns undef on failure

offsetof C-specific
open

Opens file for reading or writing; returns undef on failure

opendir

Opens directory for reading; returns undef on failure

pathconf

Retrieves value of a configurable limit on a file or directory; returns undef on failure

pause

Similar to C function pause(3) ; returns undef on failure

perror

Identical to C function perror(3)

pipe

Creates an interprocess channel

pow

Computes $x raised to the power $exponent

printf

Prints specified arguments to STDOUT

putc

C-specific; use Perl's print function

putchar

C-specific; use Perl's print function

puts

C-specific; use Perl's print function

qsort

C-specific; use Perl's sort function

raise

Sends specified signal to current process

rand

Non-portable; use Perl's rand function

read

Reads from a file; returns undef on failure

readdir

Identical to Perl's readdir function

realloc

C-specific

remove

Identical to Perl's unlink function

rename

Identical to Perl's rename function

rewind

Seeks to beginning of file

rewinddir

Identical to Perl's rewinddir function

rmdir

Identical to Perl's rmdir function

scanf

C-specific; use <> and regular expressions

setgid

Sets real group id for this process

setjmp

C-specific; use eval {}

setlocale

Modifies and queries program's locale

setpgid

Similar to C function setpgid(2) ; returns undef on failure

setsid

Identical to C function setsid(8)

setuid

Sets real user ID for this process

sigaction

Detailed signal management; returns undef on failure

siglongjmp

C-specific; use Perl's die function

sigpending

Examines blocked, pending signals and returns undef on failure

sigprocmask

Changes and/or examines this process's signal mask; returns undef on failure

sigsetjmp

C-specific; use eval {}

sigsuspend

Installs signal mask and suspends process until signal arrives; returns undef on failure

sin

Identical to Perl's sin function

sinh

Identical to C function sinh(3)

sleep

Identical to Perl's sleep function

sprintf

Identical to Perl's sprintf function

sqrt

Identical to Perl's sqrt function

srand

Identical to Perl's srand function

sscanf

C-specific; use regular expressions

stat

Identical to Perl's stat function

strcat

C-specific; use .=

strchr

C-specific; use index

strcmp

C-specific; use eq

strcoll

Identical to C function strcoll(3)

strcpy

C-specific; use =

strcspn

C-specific; use regular expressions

strerror

Returns error string for the specified errno

strftime

Converts date and time to string and returns the string

strlen

C-specific; use length

strncat

C-specific; use .= and/or substr

strncmp

C-specific; use eq and/or substr

strncpy

C-specific; use = and/or substr

stroul C-specific
strpbrk C-specific
strrchr

C-specific; use rindex and/or substr

strspn C-specific
strstr

Identical to Perl's index function

strtod C-specific
strtok C-specific
strtol C-specific
strtoul C-specific
strxfrm

String transformation; returns the transformed string

sysconf

Retrieves values of system configurable variables; returns undef on failure

system

Identical to Perl's system function

tan

Identical to C function tan(3)

tanh

Identical to C function tanh(3)

tcdrain

Similar to C function tcdrain(3) ; returns undef on failure

tcflow

Similar to C function tcflow(3) ; returns undef on failure

tcflush

Similar to C function tcflush(3) ; returns undef on failure

tcgetpgrp

Identical to C function tcgetpgrp(3)

tcsendbreak

Similar to C function tcsendbreak(3) ; returns undef on failure

tcsetpgrp

Similar to C function tcsetpgrp(3) ; returns undef on failure

time

Identical to Perl's time function

times

Returns, in clock ticks, elapsed realtime since some point in the past, user and system times for this process, and user and system times for child processes

tmpfile

Uses method FileHandle::new_tmpfile

tmpnam

Returns a name for a temporary file

tolower

Identical to Perl's lc function

toupper

Identical to Perl's uc function

ttyname

Identical to C function ttyname(3)

tzname

Retrieves time conversion information from the tzname variable

tzset

Identical to C function tzset(3)

umask

Identical to Perl's umask function

uname

Gets name of current operating system

ungetc

Uses method FileHandle::ungetc

unlink

Identical to Perl's unlink function

utime

Identical to Perl's utime function

vfprintf C-specific
vprintf C-specific
vsprintf C-specific
wait

Identical to Perl's wait function

waitpid

Waits for child process to change state; identical to Perl's waitpid function

wcstombs

Identical to C function wcstombs(3)

wctomb

Identical to C function wctomb(3)

write

Writes to file; returns undef on failure

The following sections show the classes that are defined and their methods:

8.123.4 Constants

The following constants are associated with the Termios class:

Baud rate values

B0  B75  B134 B200 B600  B1800 B4800 B19200
B50 B110 B150 B300 B1200 B2400 B9600 B38400

c_cc index values

VEOF VERASE VKILL VSUSP  VSTOP VTIME 
VEOL VINTR  VQUIT VSTART VMIN  NCCS

c_cflag field values

CLOCAL CSIZE CS6 CS8    HUPCL  PARODD
CREAD  CS5   CS7 CSTOPS PARENB

c_iflag field values

BRKINT IGNBRK IGNPAR INPCK  IXOFF PARMRK
ICRNL  IGNCR  INLCR  ISTRIP IXON

c_lflag field values

ECHO  ECHONL ISIG  
ECHOE ICANON NOFLSH
ECHOK IEXTEN TOSTOP

c_oflag field values

OPOST

Terminal interface values

TCSADRAIN TCIOFLUSH TCIFLUSH 
TCSANOW   TCOFLUSH  TCSAFLUSH 
TCOON     TCION     TCIOFF

The following are other constants defined in the POSIX module:

Pathname constants

_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

POSIX constants

_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

System configuration

_SC_ARG_MAX      _SC_CHILD_MAX  _SC_CLK_TCK    _SC_JOB_CONTROL
_SC_NGROUPS_MAX  _SC_OPEN_MAX   _SC_SAVED_IDS  _SC_STREAM_MAX
_SC_TZNAME_MAX   _SC_VERSION

Error constants

E2BIG   EACCES  EAGAIN    EBADF   EBUSY   ECHILD  EDEADLK
EDOM    EEXIST  EFAUL     EFBIG   EINTR   EINVAL  
EIO     EISDIR  EMFILE    EMLINK  ENAMETOOLONG    ENFILE  
ENODE   ENOENT  ENOEXEC   ENOLCK  ENOMEM  ENOSPC  
ENOSYS  ENOTDIR ENOTEMPTY ENOTTY  ENXIO   EPERM  
EPIPE   ERANGE  EROFS     ESPIPE  ESRCH   EXDEV

File control constants

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

Floating-point constants

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

Limit constants

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

Locale constants

LC_ALL  LC_COLLATE  LC_CTYPE  LC_MONETARY  LC_NUMERIC  LC_TIME

Math constants

HUGE_VAL

Signal constants

SA_NOCLDSTOP SIGABRT    SIGALRM    SIGCHLD  SIGCONT  SIGFPE
SIGHUP       SIGILL     SIGINT     SIGKILL  SIGPIPE  SIGQUIT
SIGSEGV      SIGSTOP    SIGTERM    SIGTSTP  SIGTTIN  SIGTTOU
SIGUSR1      SIGUSR2    SIG_BLOCK  SIG_DFL  SIG_ERR  SIG_IGN
SIG_SETMASK  SIG_UNBLOCK

Stat constants

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

Stat macros

S_ISBLK  S_ISCHR  S_ISDIR  S_ISFIFO  S_ISREG

Stdlib constants

EXIT_FAILURE  EXIT_SUCCESS  MB_CUR_MAX  RAND_MAX

Stdio constants

BUFSIZ  EOF  FILENAME_MAX  L_ctermid  L_cuserid  L_tmpname  TMP_MAX

Time constants

CLK_TCK  CLOCKS_PER_SEC

Unistd constants

R_OK   SEEK_CUR  SEEK_END       SEEK_SET  STDIN_FILENO
STDOUT_FILENO    STRERR_FILENO  W_OK      X_OK

Wait constants

WNOHANG  WUNTRACED

Wait macros

WIFEXITED  WEXITSTATUS  WIFSIGNALED  WTERMSIG   WIFSTOPPED   WSTOPSIG