unistd.h
Template:Short description Template:Use American English Script error: No such module "Unsubst". Script error: No such module "Unsubst".
Script error: No such module "Sidebar".
In the C and C++ programming languages, unistd.h is the name of the header file that provides access to the POSIX operating system API.[1] It is defined by the POSIX.1 standard, the base of the Single Unix Specification, and should therefore be available in any POSIX-compliant operating system and compiler. For instance, this includes Unix and Unix-like operating systems, such as GNU variants, distributions of Linux and BSD, and macOS, and compilers such as GCC and LLVM.
On Unix-like systems, the interface defined by unistd.h is typically made up largely of system call wrapper functions such as fork, pipe and I/O primitives (read, write, close, etc.).
Unix compatibility layers such as Cygwin and MinGW also provide their own versions of unistd.h. In fact, those systems provide it along with the translation libraries that implement its functions in terms of win32 functions. E.g. In Cygwin, a header file can be found in /usr/include that sub-includes a file of the same name in /usr/include/sys. Not everything is defined in there but some definitions are done by references to the GNU C standard library headers (like stddef.h) which provide the type size_t and many more. Thus, unistd.h is only a generically defined adaptive layer that might be based upon already existing system and compiler specific definitions. This has the general advantage of not having a possibly concurrent set of header file defined, but one that is built upon the same root which, for this reason, will raise much fewer concerns in combined usage cases.
Overview of functions
| Function | Description | |
|---|---|---|
Script error: No such module "anchor".crypt
|
password and data encryption | |
Script error: No such module "anchor".encrypt
|
encrypt 64-byte messages | |
Script error: No such module "anchor".gethostid
|
get the unique identifier of the current host | |
Script error: No such module "anchor".gethostname
|
get hostname | |
Script error: No such module "anchor".getopt
|
parse command-line options | |
Script error: No such module "anchor".swab
|
swap adjacent bytes | |
Script error: No such module "anchor".sysconf
|
get configuration at run time | |
| Signals | Script error: No such module "anchor".alarm
|
schedule an alarm signal |
Script error: No such module "anchor".pause
|
wait for signal | |
| Filesystem | Script error: No such module "anchor".accessScript error: No such module "anchor". faccessatScript error: No such module "anchor". faccessat2
|
check user's permissions for a file or whether it exists |
Script error: No such module "anchor".chdirScript error: No such module "anchor". fchdir
|
change working directory | |
Script error: No such module "anchor".chownScript error: No such module "anchor". fchownScript error: No such module "anchor". lchownScript error: No such module "anchor". fchownat
|
change owner and group of a file | |
Script error: No such module "anchor".close
|
close a file descriptor | |
Script error: No such module "anchor".dupScript error: No such module "anchor". dup2
|
duplicate a file descriptor | |
Script error: No such module "anchor".fsyncScript error: No such module "anchor". fdatasync
|
synchronize a file's in-core state with storage device | |
Script error: No such module "anchor".fpathconfScript error: No such module "anchor". pathconf
|
get configuration values for files | |
Script error: No such module "anchor".ftruncateScript error: No such module "anchor". truncate
|
truncate a file to a specified length | |
Script error: No such module "anchor".getcwdScript error: No such module "anchor". getwdScript error: No such module "anchor". get_current_dir_name |
get current working directory | |
Script error: No such module "anchor".isatty
|
test whether a file descriptor refers to a terminal | |
Script error: No such module "anchor".linkScript error: No such module "anchor". linkat
|
make a new name for a file | |
Script error: No such module "anchor".lockf
|
apply, test or remove a POSIX lock on an open file | |
Script error: No such module "anchor".lseek
|
reposition read/write file offset | |
Script error: No such module "anchor".pipeScript error: No such module "anchor". pipe2
|
create pipe | |
Script error: No such module "anchor".preadScript error: No such module "anchor". pwrite
|
read from or write to a file descriptor at a given offset | |
Script error: No such module "anchor".read
|
read from a file descriptor | |
Script error: No such module "anchor".readlinkScript error: No such module "anchor". readlinkat
|
read value of a symbolic link | |
Script error: No such module "anchor".rmdir
|
delete a directory | |
Script error: No such module "anchor".symlinkScript error: No such module "anchor". symlinkat
|
make a new name for a file | |
Script error: No such module "anchor".syncScript error: No such module "anchor". syncfs
|
commit filesystem caches to disk | |
Script error: No such module "anchor".ttynameScript error: No such module "anchor". ttyname_r
|
return name of a terminal | |
Script error: No such module "anchor".unlinkScript error: No such module "anchor". unlinkat
|
delete a name and possibly the file it refers to | |
Script error: No such module "anchor".write
|
write to a file descriptor | |
| Process | Script error: No such module "anchor"._exit
|
terminate the calling process |
Script error: No such module "anchor".execlScript error: No such module "anchor". execlpScript error: No such module "anchor". execleScript error: No such module "anchor". execvScript error: No such module "anchor". execvpScript error: No such module "anchor". execvpe
|
execute a file | |
Script error: No such module "anchor".fexecve
|
execute program specified via file descriptor | |
Script error: No such module "anchor".fork
|
create a new process | |
Script error: No such module "anchor".setpgidScript error: No such module "anchor". getpgidScript error: No such module "anchor". setpgrpScript error: No such module "anchor". getpgrp |
set/get process group | |
Script error: No such module "anchor".getpidScript error: No such module "anchor". getppid
|
get process identification | |
Script error: No such module "anchor".getsid
|
get session ID | |
Script error: No such module "anchor".nice
|
change process priority | |
Script error: No such module "anchor".setsid
|
creates a session and sets the process group ID | |
Script error: No such module "anchor".sleep
|
sleep for a specified number of seconds | |
Script error: No such module "anchor".tcgetpgrpScript error: No such module "anchor". tcsetpgrp
|
get and set terminal foreground process group | |
| User/Group | Script error: No such module "anchor".getgidScript error: No such module "anchor". getegid
|
get group identity |
Script error: No such module "anchor".getuidScript error: No such module "anchor". geteuid
|
get user identity | |
Script error: No such module "anchor".getgroups
|
get list of supplementary group IDs | |
Script error: No such module "anchor".getloginScript error: No such module "anchor". getlogin_r
|
get username | |
Script error: No such module "anchor".seteuidScript error: No such module "anchor". setegid
|
set effective user or group ID | |
Script error: No such module "anchor".setgid
|
set group identity | |
Script error: No such module "anchor".setreuidScript error: No such module "anchor". setregid
|
set real and/or effective user or group ID | |
Script error: No such module "anchor".setuid
|
set user identity |
References
<templatestyles src="Reflist/styles.css" />
- ↑ Script error: No such module "citation/CS1".
Script error: No such module "Check for unknown parameters".
External links
- : standard symbolic constants and types – Base Definitions Reference, The Single UNIX Specification, Version 5 from The Open Group