unistd(4) unistd(4)
NAME
unistd - standard symbolic constants and types
SYNOPSIS
#include <unistd.h>
DESCRIPTION
The <unistd.h> header defines miscellaneous symbolic constants and
types, and declares miscellaneous functions. The contents of this
header are shown below. The following symbolic constants are defined:
POSIXVERSION Integer value indicating version of the ISO
POSIX-1 standard (C language binding).
POSIX2VERSION Integer value indicating version of the ISO
POSIX-2 standard (Commands).
POSIX2CVERSION Integer value indicating version of the ISO
POSIX-2 standard (C language binding) and
whether the X/Open POSIX2 C-language Binding
Feature Group is supported.
XOPENVERSION Integer value indicating version of the X/Open
Portability Guide to which the implementation
conforms.
POSIXVERSION is defined in the ISO POSIX-1 standard. It changes with
each new version of the ISO POSIX-1 standard.
POSIX2VERSION is defined in the ISO POSIX-2 standard. It changes
with each new version of the ISO POSIX-2 standard.
POSIX2CVERSION is defined in the ISO POSIX-2 standard. It changes
with each new version of the ISO POSIX-2 standard. When the C language
binding option of the ISO POSIX-2 standard and therefore the X/Open
POSIX2 C-language Binding Feature Group is not supported,
POSIX2CVERSION will be set to -1.
XOPENVERSION is defined as an integer value greater than or equal to
4, indicating one of the issues of the X/Open Portability Guide to
which the implementation conforms.
XOPENXCUVERSION is defined as an integer value indicating the ver-
sion of the XCU (= X/Open Commands and Utilities) to which the imple-
mentation conforms. If the value is -1, no commands and utilities are
provided on the implementation. If the value is greater than or equal
to 4, the functionality associated with the following symbols is also
supported:
Page 1 Reliant UNIX 5.44 Printed 11/98
unistd(4) unistd(4)
POSIX2CBIND
POSIX2CVERSION
POSIX2CHARTERM
POSIX2LOCALEDEF
POSIX2UPE
POSIX2VERSION
If this constant is not defined use the sysconf() function to deter-
mine which features are supported.
Each of the following symbolic constants is defined only if the imple-
mentation supports the indicated revision of the X/Open Portability
Guide:
XOPENXPG2 X/Open Portability Guide, Volume 2, January
1987, XVS System Calls and Libraries
(ISBN: 0-444-70175-3).
XOPENXPG3 X/Open Specification, February 1992, System
Interfaces and Headers, Issue 3
(ISBN: 1-872630-37-5, C212); this specification
was formerly X/Open Portability Guide, Issue 3,
Volume 2, January 1989, XSI System Interface
and Headers (ISBN: 0-13-685843-0,
XO/XPG/89/003).
XOPENXPG4 X/Open CAE Specification, July 1992, System
Interfaces and Headers, Issue 4
(ISBN: 1-872630-47-2, C202).
XOPENUNIX X/Open CAE Specification, August 1994, System
Interfaces and Headers, Issue 4, Version 2
(ISBN: 1-85912-037-7, C435).
Mandatory Symbolic Constants
Although all implementations conforming to this description support
all of the FIPS (= Federal Information Processing Standards) features
described below, there may be system-dependent or file-system-
dependent configuration procedures that can remove or modify any or
all of these features. Such configurations should not be made if
strict FIPS compliance is required.
The following symbolic constants are either undefined or defined with
a value other than -1. If a constant is undefined, an application
should use the sysconf(), pathconf() or fpathconf() functions to
determine which features are present on the system at that time or for
the particular pathname in question.
Page 2 Reliant UNIX 5.44 Printed 11/98
unistd(4) unistd(4)
POSIXCHOWNRESTRICTED The use of chown() is restricted to a process
with appropriate privileges, and to changing
the group ID of a file only to the effective
group ID of the process or to one of its sup-
plementary group IDs.
POSIXNOTRUNC Pathname components longer than NAMEMAX gen-
erate an error.
POSIXVDISABLE Terminal special characters defined in
<termios.h> can be disabled using this char-
acter value.
POSIXSAVEDIDS Each process has a saved set-user-ID and a
saved set-group-ID.
POSIXJOBCONTROL Implementation supports job control.
POSIXCHOWNRESTRICTED, POSIXNOTRUNC and POSIXVDISABLE will have
values other than -1.
Constants for Options and Feature Groups
The following symbolic constants are defined to have the value -1 if
the implementation will never provide the feature, and to have a value
other than -1 if the implementation always provides the feature. If
these are undefined, the sysconf() function can be used to determine
whether the feature is provided for a particular invocation of the
application.
POSIX2CBIND Implementation supports the C language binding
option.
POSIX2CDEV Implementation supports the C language develop-
ment utilities option.
POSIX2CHARTERM Implementation supports at least one terminal
type.
POSIX2FORTDEV Implementation supports the FORTRAN Development
Utilities Option.
POSIX2FORTRUN Implementation supports the FORTRAN Run-time
Utilities Option.
POSIX2LOCALEDEF Implementation supports the creation of locales
by the localedef utility.
POSIX2SWDEV Implementation supports the Software Develop-
ment Utilities Option.
Page 3 Reliant UNIX 5.44 Printed 11/98
unistd(4) unistd(4)
POSIX2UPE The implementation supports the User Portabil-
ity Utilities Option.
XOPENCRYPT The implementation supports the X/Open Encryp-
tion Feature Group.
XOPENENHI18N The implementation supports the X/Open Enhanced
Internationalisation Feature Group.
XOPENSHM The implementation supports the X/Open Shared
Memory Feature Group.
Constants for Functions
The following symbolic constant is defined:
NULL Null pointer.
The following symbolic constants are defined for the access() func-
tion:
ROK Test for read permission.
WOK Test for write permission.
XOK Test for execute (search) permission.
FOK Test for existence of file.
The constants FOK, ROK, WOK and XOK and the expressions ROK |
WOK, ROK | XOK and ROK | WOK | XOK all have distinct values.
The following symbolic constant is defined for the confstr() function:
CSPATH If the ISO POSIX-2 standard is supported, this is the
value for the PATH environment variable that finds all
standard utilities. Otherwise the meaning of this
value is unspecified.
The following symbolic constants are defined for the lseek() and
fcntl() functions (they have distinct values):
SEEKSET Set file offset to offset.
SEEKCUR Set file offset to current plus offset.
SEEKEND Set file offset to EOF plus offset.
Page 4 Reliant UNIX 5.44 Printed 11/98
unistd(4) unistd(4)
The following symbolic constants are defined for sysconf():
SC2CBIND
SC2CDEV
SC2CVERSION
SC2FORTDEV
SC2FORTRUN
SC2LOCALEDEF
SC2SWDEV
SC2UPE
SC2VERSION
SCARGMAX
SCATEXITMAX
SCBCBASEMAX
SCBCDIMMAX
SCBCSCALEMAX
SCBCSTRINGMAX
SCCHILDMAX
SCCLKTCK
SCCOLLWEIGHTSMAX
SCEXPRNESTMAX
SCIOVMAX
SCJOBCONTROL
SCLINEMAX
SCNGROUPSMAX
SCOPENMAX
SCPAGESIZE
SCPAGESIZE
SCPASSMAX
SCREDUPMAX
SCSAVEDIDS
SCSTREAMMAX
SCTZNAMEMAX
SCVERSION
SCXOPENVERSION
SCXOPENCRYPT
SCXOPENENHI18N
SCXOPENSHM
SCXOPENUNIX
The two constants SCPAGESIZE and SCPAGESIZE may be defined to
have the same value.
The following symbolic constants are defined as possible values for
the function argument to the lockf() function:
FLOCK Lock a section for exclusive use.
FULOCK Unlock locked sections.
FTEST Test section for locks by other processes.
Page 5 Reliant UNIX 5.44 Printed 11/98
unistd(4) unistd(4)
FTLOCK Test and lock a section for exclusive use.
The following symbolic constants are defined for pathconf():
PCCHOWNRESTRICTED
PCFILESIZEBITS
PCLINKMAX
PCMAXCANON
PCMAXINPUT
PCNAMEMAX
PCNOTRUNC
PCPATHMAX
PCPIPEBUF
PCVDISABLE
The following symbolic constants are defined for file streams:
STDINFILENO File number of stdin. It is 0.
STDOUTFILENO File number of stdout. It is 1.
STDERRFILENO File number of stderr. It is 2.
The following pathnames are defined:
GFPATH Pathname of the group file.
PFPATH Pathname of the passwd file.
The following is declared as a function and may also be defined as a
macro [see gethostname(3N-xs)]:
int gethostname(char *address, int addresslen);
The following values for constants are defined for this release of
System V:
POSIXVERSION 199009L
XOPENVERSION 4
Type Definitions
The sizet, ssizet, uidt, gidt, offt and pidt types are defined
as described in <sys/types.h>.
The usecondst type is defined as described in <sys/types.h>.
Declarations
The following are declared as functions and may also be defined as
macros:
Page 6 Reliant UNIX 5.44 Printed 11/98
unistd(4) unistd(4)
int access(const char *path, int amode);
unsigned int alarm(unsigned int seconds);
int brk(void *addr);
int chdir(const char *path);
int chown(const char *path, uidt owner, gidt group);
int chroot(const char *path);
int close(int fildes);
sizet confstr (int name, char *buf, sizet len);
char *crypt(const char *key, const char *salt);
char *ctermid(char *s);
char *cuserid(char *s);
int dup(int fildes);
int dup2(int fildes, int fildes2);
void encrypt(char block[64], int edflag);
int execl(const char *path, const char *arg0, ...);
int execle(const char *file, const char *arg0, ...);
int execlp(const char *file, const char *arg0, ...);
int execv(const char *path, char *const argv[]);
int execve(const char *path, char *const argv[],
char *const envp[]);
int execvp(const char *file, char *const argv[]);
void exit(int status);
int fchown(int fildes, uidt owner, gidt group);
int fchdir(int fildes);
pidt fork(void);
long int fpathconf(int fildes, int name);
int fsync(int fildes);
int ftruncate(int fildes, offt length);
int ftruncate64(int fildes, off64t length);
char *getcwd(char *buf, sizet size);
int getdtablesize(void);
gidt getegid(void);
uidt geteuid(void);
gidt getgid(void);
int getgroups(int gidsetsize, gidt grouplist[]);
long gethostid(void);
char *getlogin(void);
int getopt(int argc, char * const argv[],
const char *optstring);
int getpagesize(void);
char *getpass(const char *prompt);
pidt getpgid(pidt pid);
pidt getpgrp(void);
pidt getpid(void);
pidt getppid(void);
pidt getsid(pidt pid);
uidt getuid(void);
char *getwd(char *pathname);
int isatty(int fildes);
int lchown(const char *path, uidt owner, gidt group);
int link(const char *path1, const char *path2);
int lockf(int fildes,int function,offt size);
Page 7 Reliant UNIX 5.44 Printed 11/98
unistd(4) unistd(4)
int lockf64(int fildes, int function, off64t size);
offt lseek(int fildes, offt offset, int whence);
off64t lseek64(int fildes, off64t offset, int whence);
int nice(int incr);
long int pathconf(const char *path, int name);
int pause(void);
int pipe(int fildes[2]);
ssizet read(int fildes, void *buf, sizet nbyte);
int readlink(const char *path, char *buf, sizet bufsiz);
int rmdir(const char *path);
void *sbrk(int incr);
int setgid(gidt gid);
int setpgid(pidt pid, pidt pgid);
pidt setpgrp(void);
int setregid(gidt rgid, gidt egid);
int setreuid(uidt ruid, uidt euid);
pidt setsid(void);
int setuid(uidt uid);
unsigned int sleep(unsigned int seconds);
void swab(const void *src, void *dest, ssizet nbytes);
int symlink(const char *path1, const char *path2);
void sync(void);
long int sysconf(int name);
pidt tcgetpgrp(int fildes);
int tcsetpgrp(int fildes, pidt pgrpid);
int truncate(const char *path, offt length);
int truncate64(const char *path, off64t length);
char *ttyname(int fildes);
usecondst ualarm(usecondst useconds, usecondst interval);
int unlink(const char *path);
int usleep(usecondst useconds);
pidt vfork(void);
ssizet write(int fildes, const void *buf, sizet nbyte);
The following external variables are declared:
extern char *optarg;
extern int optind, opterr, optopt;
Version Test Macros:
LFSLARGEFILE
Is defined to be 1 if the implementation supports the interfaces
as specified in "2.2.1 Changes to System Interfaces" [LFS speci-
fication, see lfs(5)] except that implementations need not pro-
vide the asynchronous I/O interfaces: aioread(), aiowrite(),
and liolistio().
Page 8 Reliant UNIX 5.44 Printed 11/98
unistd(4) unistd(4)
LFSASYNCHRONOUSIO
Is defined to be 1 if the implementation supports the asynchro-
nous IO interfaces: aioread(), aiowrite(), and liolistio() as
specified in "2.2.1 Changes to System Interfaces" [LFS specifica-
tion, see lfs(5)].
LFS64ASYNCHRONOUSIO
Is defined to be 1 if the implementation supports all the transi-
tional extensions listed in "3.1.1.1.1 Asynchronous I/O Inter-
faces" and "3.1.2.2 <aio.h>" [LFS specification, see lfs(5)].
LFS64LARGEFILE
Is defined to be 1 if the implementation supports all the transi-
tional extensions listed in "3.1.1.1.3 Other Interfaces",
"3.1.1.2 fcntl()", "3.1.1.3 open()" and "3.1.2 Transitional
Extensions to Headers", except changes specified in "3.1.2.2
<aio.h>" and "3.1.2.6 <stdio.h>" [LFS specification, see lfs(5)]
need not be supported.
LFS64STDIO
Is defined to be 1 if the implementation supports all the transi-
tional extensions listed in "3.1.1.1.2 STDIO Interfaces" and
"3.1.2.6 <stdio.h>" [LFS specification, see lfs(5)].
If LFS64STDIO is not defined to be 1 and the underlying file
description associated with stream has OLARGEFILE set then the
behavior of the standard I/O functions is unspecified.
Constants for functions:
CSLFSCFLAGS For confstr().
CSLFSLDFLAGS For confstr().
CSLFSLIBS For confstr().
CSLFSLINTFLAGS For confstr().
CSLFS64CFLAGS For confstr().
CSLFS64LDFLAGS For confstr().
CSLFS64LIBS For confstr().
CSLFS64LINTFLAGS For confstr().
SEE ALSO
access(2), alarm(2), brk(2), chdir(2), chown(2), chroot(2), close(2),
dup(2), exec(2), exit(2), fcntl(2), fork(2), fpathconf(2), fsync(2),
getgroups(2), getpid(2), getsid(2), getuid(2), link(2), lseek(2),
nice(2), pause(2), pipe(2), read(2), readlink(2), rmdir(2), setpgid(2),
setpgrp(2), setsid(2), setuid(2), symlink(2), sync(2), unlink(2),
vfork(2), write(2), getdtablesize(3), getpagesize(3), getwd(3),
ualarm(3), usleep(3), confstr(3C), crypt(3C), getcwd(3C), getlogin(3C),
getpass(3C), lockf(3C), setregid(3C), setreuid(3C), sleep(3C),
swab(3C), sysconf(3C), tcsetpgrp(3C), truncate(3C), ttyname(3C),
gethostid(3N), gethostname(3N-xs), ctermid(3S), cuserid(3S), group(4),
limits(4), passwd(4), lfs(5), termios(5), types(5).
Page 9 Reliant UNIX 5.44 Printed 11/98