--- /dev/null
+# find /usr/share/man/man2 | grep 2 | xargs pr -t | mandoc >> bsd_man2_all
+
+KQUEUE(2) System Calls Manual KQUEUE(2)
+
+N\bNA\bAM\bME\bE
+ k\bkq\bqu\bue\beu\bue\be, k\bke\bev\bve\ben\bnt\bt - kernel event notification mechanism
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/t\bty\byp\bpe\bes\bs.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/e\bev\bve\ben\bnt\bt.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/t\bti\bim\bme\be.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ k\bkq\bqu\bue\beu\bue\be(_\bv_\bo_\bi_\bd);
+
+ _\bi_\bn_\bt
+ k\bke\bev\bve\ben\bnt\bt(_\bi_\bn_\bt _\bk_\bq, _\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\bk_\be_\bv_\be_\bn_\bt _\b*_\bc_\bh_\ba_\bn_\bg_\be_\bl_\bi_\bs_\bt, _\bi_\bn_\bt _\bn_\bc_\bh_\ba_\bn_\bg_\be_\bs,
+ _\bs_\bt_\br_\bu_\bc_\bt _\bk_\be_\bv_\be_\bn_\bt _\b*_\be_\bv_\be_\bn_\bt_\bl_\bi_\bs_\bt, _\bi_\bn_\bt _\bn_\be_\bv_\be_\bn_\bt_\bs,
+ _\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\bt_\bi_\bm_\be_\bs_\bp_\be_\bc _\b*_\bt_\bi_\bm_\be_\bo_\bu_\bt);
+
+ E\bEV\bV_\b_S\bSE\bET\bT(_\b&_\bk_\be_\bv, _\bi_\bd_\be_\bn_\bt, _\bf_\bi_\bl_\bt_\be_\br, _\bf_\bl_\ba_\bg_\bs, _\bf_\bf_\bl_\ba_\bg_\bs, _\bd_\ba_\bt_\ba, _\bu_\bd_\ba_\bt_\ba);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ k\bkq\bqu\bue\beu\bue\be() provides a generic method of notifying the user when an event
+ happens or a condition holds, based on the results of small pieces of
+ kernel code termed ``filters''. A kevent is identified by the (ident,
+ filter) pair; there may only be one unique kevent per kqueue.
+
+ The filter is executed upon the initial registration of a kevent in order
+ to detect whether a preexisting condition is present, and is also
+ executed whenever an event is passed to the filter for evaluation. If
+ the filter determines that the condition should be reported, then the
+ kevent is placed on the kqueue for the user to retrieve.
+
+ The filter is also run when the user attempts to retrieve the kevent from
+ the kqueue. If the filter indicates that the condition that triggered
+ the event no longer holds, the kevent is removed from the kqueue and is
+ not returned.
+
+ Multiple events which trigger the filter do not result in multiple
+ kevents being placed on the kqueue; instead, the filter will aggregate
+ the events into a single struct kevent. Calling c\bcl\blo\bos\bse\be() on a file
+ descriptor will remove any kevents that reference the descriptor.
+
+ k\bkq\bqu\bue\beu\bue\be() creates a new kernel event queue and returns a descriptor. The
+ queue is not inherited by a child created with fork(2). Similarly,
+ kqueues cannot be passed across UNIX-domain sockets.
+
+ k\bke\bev\bve\ben\bnt\bt() is used to register events with the queue, and return any
+ pending events to the user. _\bc_\bh_\ba_\bn_\bg_\be_\bl_\bi_\bs_\bt is a pointer to an array of
+ _\bk_\be_\bv_\be_\bn_\bt structures, as defined in <_\bs_\by_\bs_\b/_\be_\bv_\be_\bn_\bt_\b._\bh>. All changes contained in
+ the _\bc_\bh_\ba_\bn_\bg_\be_\bl_\bi_\bs_\bt are applied before any pending events are read from the
+ queue. _\bn_\bc_\bh_\ba_\bn_\bg_\be_\bs gives the size of _\bc_\bh_\ba_\bn_\bg_\be_\bl_\bi_\bs_\bt. _\be_\bv_\be_\bn_\bt_\bl_\bi_\bs_\bt is a pointer to
+ an array of kevent structures. _\bn_\be_\bv_\be_\bn_\bt_\bs determines the size of _\be_\bv_\be_\bn_\bt_\bl_\bi_\bs_\bt.
+ When _\bn_\be_\bv_\be_\bn_\bt_\bs is zero, k\bke\bev\bve\ben\bnt\bt() will return immediately even if there is a
+ _\bt_\bi_\bm_\be_\bo_\bu_\bt specified unlike select(2). If _\bt_\bi_\bm_\be_\bo_\bu_\bt is a non-null pointer, it
+ specifies a maximum interval to wait for an event, which will be
+ interpreted as a struct timespec. If _\bt_\bi_\bm_\be_\bo_\bu_\bt is a null pointer, k\bke\bev\bve\ben\bnt\bt()
+ waits indefinitely. To effect a poll, the _\bt_\bi_\bm_\be_\bo_\bu_\bt argument should be
+ non-null, pointing to a zero-valued _\bt_\bi_\bm_\be_\bs_\bp_\be_\bc structure. The same array
+ may be used for the _\bc_\bh_\ba_\bn_\bg_\be_\bl_\bi_\bs_\bt and _\be_\bv_\be_\bn_\bt_\bl_\bi_\bs_\bt.
+
+ E\bEV\bV_\b_S\bSE\bET\bT() is a macro which is provided for ease of initializing a kevent
+ structure.
+
+ The _\bk_\be_\bv_\be_\bn_\bt structure is defined as:
+
+ struct kevent {
+ uintptr_t ident; /* identifier for this event */
+ short filter; /* filter for event */
+ u_short flags; /* action flags for kqueue */
+ u_int fflags; /* filter flag value */
+ quad_t data; /* filter data value */
+ void *udata; /* opaque user data identifier */
+ };
+
+ The fields of struct kevent are:
+
+ ident Value used to identify this event. The exact interpretation
+ is determined by the attached filter, but often is a file
+ descriptor.
+
+ filter Identifies the kernel filter used to process this event. The
+ pre-defined system filters are described below.
+
+ flags Actions to perform on the event.
+
+ fflags Filter-specific flags.
+
+ data Filter-specific data value.
+
+ udata Opaque user-defined value passed through the kernel unchanged.
+
+ The _\bf_\bl_\ba_\bg_\bs field can contain the following values:
+
+ EV_ADD Adds the event to the kqueue. Re-adding an existing event
+ will modify the parameters of the original event, and not
+ result in a duplicate entry. Adding an event
+ automatically enables it, unless overridden by the
+ EV_DISABLE flag.
+
+ EV_ENABLE Permit k\bke\bev\bve\ben\bnt\bt() to return the event if it is triggered.
+
+ EV_DISABLE Disable the event so k\bke\bev\bve\ben\bnt\bt() will not return it. The
+ filter itself is not disabled.
+
+ EV_DELETE Removes the event from the kqueue. Events which are
+ attached to file descriptors are automatically deleted on
+ the last close of the descriptor.
+
+ EV_ONESHOT Causes the event to return only the first occurrence of
+ the filter being triggered. After the user retrieves the
+ event from the kqueue, it is deleted.
+
+ EV_CLEAR After the event is retrieved by the user, its state is
+ reset. This is useful for filters which report state
+ transitions instead of the current state. Note that some
+ filters may automatically set this flag internally.
+
+ EV_EOF Filters may set this flag to indicate filter-specific EOF
+ condition.
+
+ EV_ERROR See _\bR_\bE_\bT_\bU_\bR_\bN _\bV_\bA_\bL_\bU_\bE_\bS below.
+
+ The predefined system filters are listed below. Arguments may be passed
+ to and from the filter via the _\bf_\bf_\bl_\ba_\bg_\bs and _\bd_\ba_\bt_\ba fields in the kevent
+ structure.
+
+ EVFILT_READ Takes a descriptor as the identifier, and returns whenever
+ there is data available to read. The behavior of the
+ filter is slightly different depending on the descriptor
+ type.
+
+ Sockets
+ Sockets which have previously been passed to l\bli\bis\bst\bte\ben\bn()
+ return when there is an incoming connection pending.
+ _\bd_\ba_\bt_\ba contains the size of the listen backlog.
+
+ Other socket descriptors return when there is data to
+ be read, subject to the SO_RCVLOWAT value of the
+ socket buffer. This may be overridden with a per-
+ filter low water mark at the time the filter is added
+ by setting the NOTE_LOWAT flag in _\bf_\bf_\bl_\ba_\bg_\bs, and
+ specifying the new low water mark in _\bd_\ba_\bt_\ba. On return,
+ _\bd_\ba_\bt_\ba contains the number of bytes in the socket
+ buffer.
+
+ If the read direction of the socket has shutdown, then
+ the filter also sets EV_EOF in _\bf_\bl_\ba_\bg_\bs, and returns the
+ socket error (if any) in _\bf_\bf_\bl_\ba_\bg_\bs. It is possible for
+ EOF to be returned (indicating the connection is gone)
+ while there is still data pending in the socket
+ buffer.
+
+ Vnodes
+ Returns when the file pointer is not at the end of
+ file. _\bd_\ba_\bt_\ba contains the offset from current position
+ to end of file, and may be negative. If NOTE_EOF is
+ set in _\bf_\bf_\bl_\ba_\bg_\bs, k\bke\bev\bve\ben\bnt\bt() will also return when the file
+ pointer is at the end of file. The end of file
+ condition is indicated by the presence of NOTE_EOF in
+ _\bf_\bf_\bl_\ba_\bg_\bs on return.
+
+ Fifos, Pipes
+ Returns when there is data to read; _\bd_\ba_\bt_\ba contains the
+ number of bytes available.
+
+ When the last writer disconnects, the filter will set
+ EV_EOF in _\bf_\bl_\ba_\bg_\bs. This may be cleared by passing in
+ EV_CLEAR, at which point the filter will resume
+ waiting for data to become available before returning.
+
+ BPF devices
+ Returns when the BPF buffer is full, the BPF timeout
+ has expired, or when the BPF has ``immediate mode''
+ enabled and there is any data to read; _\bd_\ba_\bt_\ba contains
+ the number of bytes available.
+
+ EVFILT_WRITE Takes a descriptor as the identifier, and returns whenever
+ it is possible to write to the descriptor. For sockets,
+ pipes, and FIFOs, _\bd_\ba_\bt_\ba will contain the amount of space
+ remaining in the write buffer. The filter will set EV_EOF
+ when the reader disconnects, and for the FIFO case, this
+ may be cleared by use of EV_CLEAR. Note that this filter
+ is not supported for vnodes or BPF devices.
+
+ For sockets, the low water mark and socket error handling
+ is identical to the EVFILT_READ case.
+
+ EVFILT_VNODE Takes a file descriptor as the identifier and the events
+ to watch for in _\bf_\bf_\bl_\ba_\bg_\bs, and returns when one or more of
+ the requested events occurs on the descriptor. The events
+ to monitor are:
+
+ NOTE_DELETE u\bun\bnl\bli\bin\bnk\bk() was called on the file referenced
+ by the descriptor.
+
+ NOTE_WRITE A write occurred on the file referenced by
+ the descriptor.
+
+ NOTE_EXTEND The file referenced by the descriptor was
+ extended.
+
+ NOTE_TRUNCATE The file referenced by the descriptor was
+ truncated.
+
+ NOTE_ATTRIB The file referenced by the descriptor had
+ its attributes changed.
+
+ NOTE_LINK The link count on the file changed.
+
+ NOTE_RENAME The file referenced by the descriptor was
+ renamed.
+
+ NOTE_REVOKE Access to the file was revoked via
+ revoke(2) or the underlying file system was
+ unmounted.
+
+ On return, _\bf_\bf_\bl_\ba_\bg_\bs contains the events which triggered the
+ filter.
+
+ EVFILT_PROC Takes the process ID to monitor as the identifier and the
+ events to watch for in _\bf_\bf_\bl_\ba_\bg_\bs, and returns when the
+ process performs one or more of the requested events. If
+ a process can normally see another process, it can attach
+ an event to it. The events to monitor are:
+
+ NOTE_EXIT The process has exited. The exit status
+ will be stored in _\bd_\ba_\bt_\ba in the same format
+ as the status set by wait(2).
+
+ NOTE_FORK The process has called f\bfo\bor\brk\bk().
+
+ NOTE_EXEC The process has executed a new process
+ via execve(2) or similar call.
+
+ NOTE_TRACK Follow a process across f\bfo\bor\brk\bk() calls.
+ The parent process will return with
+ NOTE_FORK set in the _\bf_\bf_\bl_\ba_\bg_\bs field, while
+ the child process will return with
+ NOTE_CHILD set in _\bf_\bf_\bl_\ba_\bg_\bs and the parent
+ PID in _\bd_\ba_\bt_\ba.
+
+ NOTE_TRACKERR This flag is returned if the system was
+ unable to attach an event to the child
+ process, usually due to resource
+ limitations.
+
+ On return, _\bf_\bf_\bl_\ba_\bg_\bs contains the events which triggered the
+ filter.
+
+ EVFILT_SIGNAL Takes the signal number to monitor as the identifier and
+ returns when the given signal is delivered to the process.
+ This coexists with the s\bsi\big\bgn\bna\bal\bl() and s\bsi\big\bga\bac\bct\bti\bio\bon\bn()
+ facilities, and has a lower precedence. The filter will
+ record all attempts to deliver a signal to a process, even
+ if the signal has been marked as SIG_IGN. Event
+ notification happens after normal signal delivery
+ processing. _\bd_\ba_\bt_\ba returns the number of times the signal
+ has occurred since the last call to k\bke\bev\bve\ben\bnt\bt(). This filter
+ automatically sets the EV_CLEAR flag internally.
+
+ EVFILT_TIMER Establishes an arbitrary timer identified by _\bi_\bd_\be_\bn_\bt. When
+ adding a timer, _\bd_\ba_\bt_\ba specifies the timeout period in
+ milliseconds. The timer will be periodic unless
+ EV_ONESHOT is specified. On return, _\bd_\ba_\bt_\ba contains the
+ number of times the timeout has expired since the last
+ call to k\bke\bev\bve\ben\bnt\bt(). This filter automatically sets the
+ EV_CLEAR flag internally.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ k\bkq\bqu\bue\beu\bue\be() creates a new kernel event queue and returns a file descriptor.
+ If there was an error creating the kernel event queue, a value of -1 is
+ returned and errno set.
+
+ k\bke\bev\bve\ben\bnt\bt() returns the number of events placed in the _\be_\bv_\be_\bn_\bt_\bl_\bi_\bs_\bt, up to the
+ value given by _\bn_\be_\bv_\be_\bn_\bt_\bs. If an error occurs while processing an element
+ of the _\bc_\bh_\ba_\bn_\bg_\be_\bl_\bi_\bs_\bt and there is enough room in the _\be_\bv_\be_\bn_\bt_\bl_\bi_\bs_\bt, then the
+ event will be placed in the _\be_\bv_\be_\bn_\bt_\bl_\bi_\bs_\bt with EV_ERROR set in _\bf_\bl_\ba_\bg_\bs and the
+ system error in _\bd_\ba_\bt_\ba. Otherwise, -1 will be returned, and errno will be
+ set to indicate the error condition. If the time limit expires, then
+ k\bke\bev\bve\ben\bnt\bt() returns 0.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ The k\bkq\bqu\bue\beu\bue\be() function fails if:
+
+ [ENOMEM] The kernel failed to allocate enough memory for the
+ kernel queue.
+
+ [EMFILE] The per-process descriptor table is full.
+
+ [ENFILE] The system file table is full.
+
+ The k\bke\bev\bve\ben\bnt\bt() function fails if:
+
+ [EACCES] The process does not have permission to register a
+ filter.
+
+ [EFAULT] There was an error reading or writing the _\bk_\be_\bv_\be_\bn_\bt
+ structure.
+
+ [EBADF] The specified descriptor is invalid.
+
+ [EINTR] A signal was delivered before the timeout expired and
+ before any events were placed on the kqueue for
+ return.
+
+ [EINVAL] The specified time limit or filter is invalid.
+
+ [ENOENT] The event could not be found to be modified or
+ deleted.
+
+ [ENOMEM] No memory was available to register the event.
+
+ [ESRCH] The specified process to attach to does not exist.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ poll(2), read(2), select(2), sigaction(2), wait(2), write(2), signal(3)
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The k\bkq\bqu\bue\beu\bue\be() and k\bke\bev\bve\ben\bnt\bt() functions first appeared in FreeBSD 4.1.
+
+A\bAU\bUT\bTH\bHO\bOR\bRS\bS
+ The k\bkq\bqu\bue\beu\bue\be() system and this manual page were written by Jonathan Lemon
+ <_\bj_\bl_\be_\bm_\bo_\bn_\b@_\bF_\br_\be_\be_\bB_\bS_\bD_\b._\bo_\br_\bg>.
+
+B\bBU\bUG\bGS\bS
+ It is currently not possible to watch FIFOs or AIO that reside on
+ anything but a UFS file system. Watching a vnode is possible on UFS, NFS
+ and MS-DOS file systems.
+
+ The _\bt_\bi_\bm_\be_\bo_\bu_\bt value is limited to 24 hours; longer timeouts will be
+ silently reinterpreted as 24 hours.
+
+N\bNA\bAM\bME\bE
+ s\bst\bta\bat\bt, l\bls\bst\bta\bat\bt, f\bfs\bst\bta\bat\bta\bat\bt, f\bfs\bst\bta\bat\bt - get file status
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ s\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ l\bls\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<f\bfc\bcn\bnt\btl\bl.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb, _\bi_\bn_\bt _\bf_\bl_\ba_\bg);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The s\bst\bta\bat\bt() function obtains information about the file pointed to by
+ _\bp_\ba_\bt_\bh. Read, write, or execute permission of the named file is not
+ required, but all directories listed in the path name leading to the file
+ must be searchable.
+
+ The l\bls\bst\bta\bat\bt() function is identical to s\bst\bta\bat\bt() except when the named file is
+ a symbolic link, in which case l\bls\bst\bta\bat\bt() returns information about the link
+ itself, not the file the link references.
+
+ The f\bfs\bst\bta\bat\bta\bat\bt() function is equivalent to either the s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt()
+ function depending on the value of _\bf_\bl_\ba_\bg (see below), except that where
+ _\bp_\ba_\bt_\bh specifies a relative path, the file whose information is returned is
+ determined relative to the directory associated with file descriptor _\bf_\bd
+ instead of the current working directory.
+
+ If f\bfs\bst\bta\bat\bta\bat\bt() is passed the special value AT_FDCWD (defined in <_\bf_\bc_\bn_\bt_\bl_\b._\bh>)
+ in the _\bf_\bd parameter, the current working directory is used and the
+ behavior is identical to a call to s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt(), depending on
+ whether or not the AT_SYMLINK_NOFOLLOW bit is set in _\bf_\bl_\ba_\bg.
+
+ The _\bf_\bl_\ba_\bg argument is the bitwise OR of zero or more of the following
+ values:
+
+ AT_SYMLINK_NOFOLLOW If _\bp_\ba_\bt_\bh names a symbolic link, then the status
+ of the symbolic link is returned.
+
+ The f\bfs\bst\bta\bat\bt() function obtains the same information about an open file
+ known by the file descriptor _\bf_\bd.
+
+ The _\bs_\bb argument is a pointer to a s\bst\bta\bat\bt() structure as defined by
+ <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> (shown below) and into which information is placed
+ concerning the file.
+
+ struct stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ blkcnt_t st_blocks; /* blocks allocated for file */
+ blksize_t st_blksize;/* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ };
+
+ The time-related fields of struct stat are represented in struct timespec
+ format, which has nanosecond precision. However, the actual precision is
+ generally limited by the file system holding the file. The fields are as
+ follows:
+
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm Time when file data was last accessed. Set when the file
+ system object was created and updated by the utimes(2) and
+ read(2) system calls.
+
+ _\bs_\bt_\b__\bm_\bt_\bi_\bm Time when file data was last modified. Changed by the
+ truncate(2), utimes(2), and write(2) system calls. For
+ directories, changed by any system call that alters which
+ files are in the directory, such as the unlink(2), rename(2),
+ mkdir(2), and symlink(2) system calls.
+
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm Time when file status was last changed (inode data
+ modification). Changed by the chmod(2), chown(2), link(2),
+ rename(2), unlink(2), utimes(2), and write(2) system calls.
+
+ In addition, all the time fields are set to the current time when a file
+ system object is first created by the mkdir(2), mkfifo(2), mknod(2),
+ open(2), and symlink(2) system calls.
+
+ For compatibility with previous standards, _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be, and
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be macros are provided that expand to the _\bt_\bv_\b__\bs_\be_\bc_\bs member of their
+ respective struct timespec member. Deprecated macros are also provided
+ for some transitional names: _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc,
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, and _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc
+
+ The size-related fields of the struct stat are as follows:
+
+ _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be The optimal I/O block size for the file.
+
+ _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs The actual number of blocks allocated for the file in
+ 512-byte units. As short symbolic links are stored in the
+ inode, this number may be zero.
+
+ The status information word _\bs_\bt_\b__\bm_\bo_\bd_\be has the following bits:
+
+ #define S_IFMT 0170000 /* type of file mask */
+ #define S_IFIFO 0010000 /* named pipe (fifo) */
+ #define S_IFCHR 0020000 /* character special */
+ #define S_IFDIR 0040000 /* directory */
+ #define S_IFBLK 0060000 /* block special */
+ #define S_IFREG 0100000 /* regular */
+ #define S_IFLNK 0120000 /* symbolic link */
+ #define S_IFSOCK 0140000 /* socket */
+ #define S_ISUID 0004000 /* set-user-ID on execution */
+ #define S_ISGID 0002000 /* set-group-ID on execution */
+ #define S_ISVTX 0001000 /* save swapped text even after use */
+ #define S_IRWXU 0000700 /* RWX mask for owner */
+ #define S_IRUSR 0000400 /* R for owner */
+ #define S_IWUSR 0000200 /* W for owner */
+ #define S_IXUSR 0000100 /* X for owner */
+ #define S_IRWXG 0000070 /* RWX mask for group */
+ #define S_IRGRP 0000040 /* R for group */
+ #define S_IWGRP 0000020 /* W for group */
+ #define S_IXGRP 0000010 /* X for group */
+ #define S_IRWXO 0000007 /* RWX mask for other */
+ #define S_IROTH 0000004 /* R for other */
+ #define S_IWOTH 0000002 /* W for other */
+ #define S_IXOTH 0000001 /* X for other */
+
+ The following macros test a file's type. If the file is of that type, a
+ non-zero value is returned; otherwise, 0 is returned.
+
+ S_ISBLK(st_mode m) /* block special */
+ S_ISCHR(st_mode m) /* char special */
+ S_ISDIR(st_mode m) /* directory */
+ S_ISFIFO(st_mode m) /* fifo */
+ S_ISLNK(st_mode m) /* symbolic link */
+ S_ISREG(st_mode m) /* regular file */
+ S_ISSOCK(st_mode m) /* socket */
+
+ For a list of access modes, see <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh>, access(2), and chmod(2).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ Upon successful completion, the value 0 is returned; otherwise the
+ value -1 is returned and the global variable _\be_\br_\br_\bn_\bo is set to indicate the
+ error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ s\bst\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [ENOTDIR] A component of the path prefix is not a directory.
+
+ [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX
+ characters, or an entire pathname (including the
+ terminating NUL) exceeded PATH_MAX bytes.
+
+ [ENOENT] A component of _\bn_\ba_\bm_\be does not exist or _\bn_\ba_\bm_\be is the
+ empty path.
+
+ [EACCES] Search permission is denied for a component of the
+ path prefix.
+
+ [ELOOP] Too many symbolic links were encountered in
+ translating the pathname.
+
+ [EFAULT] _\bs_\bb or _\bn_\ba_\bm_\be points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from or writing to
+ the file system.
+
+ Additionally, f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [EINVAL] The value of the _\bf_\bl_\ba_\bg argument was neither zero nor
+ AT_SYMLINK_NOFOLLOW.
+
+ [EBADF] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is neither AT_FDCWD nor a valid file
+ descriptor.
+
+ [ENOTDIR] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is a valid file descriptor but it does not
+ reference a directory.
+
+ [EACCES] The _\bp_\ba_\bt_\bh argument specifies a relative path but search
+ permission is denied for the directory which the _\bf_\bd
+ file descriptor references.
+
+ f\bfs\bst\bta\bat\bt() will fail if:
+
+ [EBADF] _\bf_\bd is not a valid open file descriptor.
+
+ [EFAULT] _\bs_\bb points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from the file
+ system.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ chmod(2), chown(2), clock_gettime(2), utimes(2), symlink(7)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ Previous versions of the system used different types for the _\bs_\bt_\b__\bd_\be_\bv,
+ _\bs_\bt_\b__\bu_\bi_\bd, _\bs_\bt_\b__\bg_\bi_\bd, _\bs_\bt_\b__\br_\bd_\be_\bv, _\bs_\bt_\b__\bs_\bi_\bz_\be, _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be, and _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs fields.
+
+ The f\bfs\bst\bta\bat\bt(), f\bfs\bst\bta\bat\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and s\bst\bta\bat\bt() functions are intended to
+ conform to IEEE Std 1003.1-2008 (``POSIX.1'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The s\bst\bta\bat\bt() and f\bfs\bst\bta\bat\bt() system calls first appeared in Version 1 AT&T
+ UNIX. The <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> header file and the _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt were introduced
+ in Version 7 AT&T UNIX.
+
+ An l\bls\bst\bta\bat\bt() function call appeared in 4.2BSD. The f\bfs\bst\bta\bat\bta\bat\bt() function
+ appeared in OpenBSD 5.0.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ The file generation number, _\bs_\bt_\b__\bg_\be_\bn, is only available to the superuser.
+
+ Certain programs written when the timestamps were just of type time_t
+ assumed that the members were consecutive (and could therefore be treated
+ as an array and have their address passed directly to utime(3)). The
+ transition to timestamps of type struct timespec broke them irrevocably.
+
+B\bBU\bUG\bGS\bS
+ Applying f\bfs\bst\bta\bat\bt() to a pipe or socket fails to fill in a unique device and
+ inode number pair. Applying f\bfs\bst\bta\bat\bt() to a socket also fails to fill in
+ the time fields.
+
+N\bNA\bAM\bME\bE
+ s\bst\bta\bat\bt, l\bls\bst\bta\bat\bt, f\bfs\bst\bta\bat\bta\bat\bt, f\bfs\bst\bta\bat\bt - get file status
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ s\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ l\bls\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<f\bfc\bcn\bnt\btl\bl.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb, _\bi_\bn_\bt _\bf_\bl_\ba_\bg);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The s\bst\bta\bat\bt() function obtains information about the file pointed to by
+ _\bp_\ba_\bt_\bh. Read, write, or execute permission of the named file is not
+ required, but all directories listed in the path name leading to the file
+ must be searchable.
+
+ The l\bls\bst\bta\bat\bt() function is identical to s\bst\bta\bat\bt() except when the named file is
+ a symbolic link, in which case l\bls\bst\bta\bat\bt() returns information about the link
+ itself, not the file the link references.
+
+ The f\bfs\bst\bta\bat\bta\bat\bt() function is equivalent to either the s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt()
+ function depending on the value of _\bf_\bl_\ba_\bg (see below), except that where
+ _\bp_\ba_\bt_\bh specifies a relative path, the file whose information is returned is
+ determined relative to the directory associated with file descriptor _\bf_\bd
+ instead of the current working directory.
+
+ If f\bfs\bst\bta\bat\bta\bat\bt() is passed the special value AT_FDCWD (defined in <_\bf_\bc_\bn_\bt_\bl_\b._\bh>)
+ in the _\bf_\bd parameter, the current working directory is used and the
+ behavior is identical to a call to s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt(), depending on
+ whether or not the AT_SYMLINK_NOFOLLOW bit is set in _\bf_\bl_\ba_\bg.
+
+ The _\bf_\bl_\ba_\bg argument is the bitwise OR of zero or more of the following
+ values:
+
+ AT_SYMLINK_NOFOLLOW If _\bp_\ba_\bt_\bh names a symbolic link, then the status
+ of the symbolic link is returned.
+
+ The f\bfs\bst\bta\bat\bt() function obtains the same information about an open file
+ known by the file descriptor _\bf_\bd.
+
+ The _\bs_\bb argument is a pointer to a s\bst\bta\bat\bt() structure as defined by
+ <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> (shown below) and into which information is placed
+ concerning the file.
+
+ struct stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ blkcnt_t st_blocks; /* blocks allocated for file */
+ blksize_t st_blksize;/* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ };
+
+ The time-related fields of struct stat are represented in struct timespec
+ format, which has nanosecond precision. However, the actual precision is
+ generally limited by the file system holding the file. The fields are as
+ follows:
+
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm Time when file data was last accessed. Set when the file
+ system object was created and updated by the utimes(2) and
+ read(2) system calls.
+
+ _\bs_\bt_\b__\bm_\bt_\bi_\bm Time when file data was last modified. Changed by the
+ truncate(2), utimes(2), and write(2) system calls. For
+ directories, changed by any system call that alters which
+ files are in the directory, such as the unlink(2), rename(2),
+ mkdir(2), and symlink(2) system calls.
+
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm Time when file status was last changed (inode data
+ modification). Changed by the chmod(2), chown(2), link(2),
+ rename(2), unlink(2), utimes(2), and write(2) system calls.
+
+ In addition, all the time fields are set to the current time when a file
+ system object is first created by the mkdir(2), mkfifo(2), mknod(2),
+ open(2), and symlink(2) system calls.
+
+ For compatibility with previous standards, _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be, and
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be macros are provided that expand to the _\bt_\bv_\b__\bs_\be_\bc_\bs member of their
+ respective struct timespec member. Deprecated macros are also provided
+ for some transitional names: _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc,
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, and _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc
+
+ The size-related fields of the struct stat are as follows:
+
+ _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be The optimal I/O block size for the file.
+
+ _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs The actual number of blocks allocated for the file in
+ 512-byte units. As short symbolic links are stored in the
+ inode, this number may be zero.
+
+ The status information word _\bs_\bt_\b__\bm_\bo_\bd_\be has the following bits:
+
+ #define S_IFMT 0170000 /* type of file mask */
+ #define S_IFIFO 0010000 /* named pipe (fifo) */
+ #define S_IFCHR 0020000 /* character special */
+ #define S_IFDIR 0040000 /* directory */
+ #define S_IFBLK 0060000 /* block special */
+ #define S_IFREG 0100000 /* regular */
+ #define S_IFLNK 0120000 /* symbolic link */
+ #define S_IFSOCK 0140000 /* socket */
+ #define S_ISUID 0004000 /* set-user-ID on execution */
+ #define S_ISGID 0002000 /* set-group-ID on execution */
+ #define S_ISVTX 0001000 /* save swapped text even after use */
+ #define S_IRWXU 0000700 /* RWX mask for owner */
+ #define S_IRUSR 0000400 /* R for owner */
+ #define S_IWUSR 0000200 /* W for owner */
+ #define S_IXUSR 0000100 /* X for owner */
+ #define S_IRWXG 0000070 /* RWX mask for group */
+ #define S_IRGRP 0000040 /* R for group */
+ #define S_IWGRP 0000020 /* W for group */
+ #define S_IXGRP 0000010 /* X for group */
+ #define S_IRWXO 0000007 /* RWX mask for other */
+ #define S_IROTH 0000004 /* R for other */
+ #define S_IWOTH 0000002 /* W for other */
+ #define S_IXOTH 0000001 /* X for other */
+
+ The following macros test a file's type. If the file is of that type, a
+ non-zero value is returned; otherwise, 0 is returned.
+
+ S_ISBLK(st_mode m) /* block special */
+ S_ISCHR(st_mode m) /* char special */
+ S_ISDIR(st_mode m) /* directory */
+ S_ISFIFO(st_mode m) /* fifo */
+ S_ISLNK(st_mode m) /* symbolic link */
+ S_ISREG(st_mode m) /* regular file */
+ S_ISSOCK(st_mode m) /* socket */
+
+ For a list of access modes, see <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh>, access(2), and chmod(2).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ Upon successful completion, the value 0 is returned; otherwise the
+ value -1 is returned and the global variable _\be_\br_\br_\bn_\bo is set to indicate the
+ error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ s\bst\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [ENOTDIR] A component of the path prefix is not a directory.
+
+ [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX
+ characters, or an entire pathname (including the
+ terminating NUL) exceeded PATH_MAX bytes.
+
+ [ENOENT] A component of _\bn_\ba_\bm_\be does not exist or _\bn_\ba_\bm_\be is the
+ empty path.
+
+ [EACCES] Search permission is denied for a component of the
+ path prefix.
+
+ [ELOOP] Too many symbolic links were encountered in
+ translating the pathname.
+
+ [EFAULT] _\bs_\bb or _\bn_\ba_\bm_\be points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from or writing to
+ the file system.
+
+ Additionally, f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [EINVAL] The value of the _\bf_\bl_\ba_\bg argument was neither zero nor
+ AT_SYMLINK_NOFOLLOW.
+
+ [EBADF] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is neither AT_FDCWD nor a valid file
+ descriptor.
+
+ [ENOTDIR] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is a valid file descriptor but it does not
+ reference a directory.
+
+ [EACCES] The _\bp_\ba_\bt_\bh argument specifies a relative path but search
+ permission is denied for the directory which the _\bf_\bd
+ file descriptor references.
+
+ f\bfs\bst\bta\bat\bt() will fail if:
+
+ [EBADF] _\bf_\bd is not a valid open file descriptor.
+
+ [EFAULT] _\bs_\bb points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from the file
+ system.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ chmod(2), chown(2), clock_gettime(2), utimes(2), symlink(7)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ Previous versions of the system used different types for the _\bs_\bt_\b__\bd_\be_\bv,
+ _\bs_\bt_\b__\bu_\bi_\bd, _\bs_\bt_\b__\bg_\bi_\bd, _\bs_\bt_\b__\br_\bd_\be_\bv, _\bs_\bt_\b__\bs_\bi_\bz_\be, _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be, and _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs fields.
+
+ The f\bfs\bst\bta\bat\bt(), f\bfs\bst\bta\bat\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and s\bst\bta\bat\bt() functions are intended to
+ conform to IEEE Std 1003.1-2008 (``POSIX.1'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The s\bst\bta\bat\bt() and f\bfs\bst\bta\bat\bt() system calls first appeared in Version 1 AT&T
+ UNIX. The <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> header file and the _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt were introduced
+ in Version 7 AT&T UNIX.
+
+ An l\bls\bst\bta\bat\bt() function call appeared in 4.2BSD. The f\bfs\bst\bta\bat\bta\bat\bt() function
+ appeared in OpenBSD 5.0.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ The file generation number, _\bs_\bt_\b__\bg_\be_\bn, is only available to the superuser.
+
+ Certain programs written when the timestamps were just of type time_t
+ assumed that the members were consecutive (and could therefore be treated
+ as an array and have their address passed directly to utime(3)). The
+ transition to timestamps of type struct timespec broke them irrevocably.
+
+B\bBU\bUG\bGS\bS
+ Applying f\bfs\bst\bta\bat\bt() to a pipe or socket fails to fill in a unique device and
+ inode number pair. Applying f\bfs\bst\bta\bat\bt() to a socket also fails to fill in
+ the time fields.
+
+N\bNA\bAM\bME\bE
+ s\bst\bta\bat\bt, l\bls\bst\bta\bat\bt, f\bfs\bst\bta\bat\bta\bat\bt, f\bfs\bst\bta\bat\bt - get file status
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ s\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ l\bls\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<f\bfc\bcn\bnt\btl\bl.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb, _\bi_\bn_\bt _\bf_\bl_\ba_\bg);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The s\bst\bta\bat\bt() function obtains information about the file pointed to by
+ _\bp_\ba_\bt_\bh. Read, write, or execute permission of the named file is not
+ required, but all directories listed in the path name leading to the file
+ must be searchable.
+
+ The l\bls\bst\bta\bat\bt() function is identical to s\bst\bta\bat\bt() except when the named file is
+ a symbolic link, in which case l\bls\bst\bta\bat\bt() returns information about the link
+ itself, not the file the link references.
+
+ The f\bfs\bst\bta\bat\bta\bat\bt() function is equivalent to either the s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt()
+ function depending on the value of _\bf_\bl_\ba_\bg (see below), except that where
+ _\bp_\ba_\bt_\bh specifies a relative path, the file whose information is returned is
+ determined relative to the directory associated with file descriptor _\bf_\bd
+ instead of the current working directory.
+
+ If f\bfs\bst\bta\bat\bta\bat\bt() is passed the special value AT_FDCWD (defined in <_\bf_\bc_\bn_\bt_\bl_\b._\bh>)
+ in the _\bf_\bd parameter, the current working directory is used and the
+ behavior is identical to a call to s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt(), depending on
+ whether or not the AT_SYMLINK_NOFOLLOW bit is set in _\bf_\bl_\ba_\bg.
+
+ The _\bf_\bl_\ba_\bg argument is the bitwise OR of zero or more of the following
+ values:
+
+ AT_SYMLINK_NOFOLLOW If _\bp_\ba_\bt_\bh names a symbolic link, then the status
+ of the symbolic link is returned.
+
+ The f\bfs\bst\bta\bat\bt() function obtains the same information about an open file
+ known by the file descriptor _\bf_\bd.
+
+ The _\bs_\bb argument is a pointer to a s\bst\bta\bat\bt() structure as defined by
+ <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> (shown below) and into which information is placed
+ concerning the file.
+
+ struct stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ blkcnt_t st_blocks; /* blocks allocated for file */
+ blksize_t st_blksize;/* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ };
+
+ The time-related fields of struct stat are represented in struct timespec
+ format, which has nanosecond precision. However, the actual precision is
+ generally limited by the file system holding the file. The fields are as
+ follows:
+
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm Time when file data was last accessed. Set when the file
+ system object was created and updated by the utimes(2) and
+ read(2) system calls.
+
+ _\bs_\bt_\b__\bm_\bt_\bi_\bm Time when file data was last modified. Changed by the
+ truncate(2), utimes(2), and write(2) system calls. For
+ directories, changed by any system call that alters which
+ files are in the directory, such as the unlink(2), rename(2),
+ mkdir(2), and symlink(2) system calls.
+
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm Time when file status was last changed (inode data
+ modification). Changed by the chmod(2), chown(2), link(2),
+ rename(2), unlink(2), utimes(2), and write(2) system calls.
+
+ In addition, all the time fields are set to the current time when a file
+ system object is first created by the mkdir(2), mkfifo(2), mknod(2),
+ open(2), and symlink(2) system calls.
+
+ For compatibility with previous standards, _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be, and
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be macros are provided that expand to the _\bt_\bv_\b__\bs_\be_\bc_\bs member of their
+ respective struct timespec member. Deprecated macros are also provided
+ for some transitional names: _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc,
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, and _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc
+
+ The size-related fields of the struct stat are as follows:
+
+ _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be The optimal I/O block size for the file.
+
+ _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs The actual number of blocks allocated for the file in
+ 512-byte units. As short symbolic links are stored in the
+ inode, this number may be zero.
+
+ The status information word _\bs_\bt_\b__\bm_\bo_\bd_\be has the following bits:
+
+ #define S_IFMT 0170000 /* type of file mask */
+ #define S_IFIFO 0010000 /* named pipe (fifo) */
+ #define S_IFCHR 0020000 /* character special */
+ #define S_IFDIR 0040000 /* directory */
+ #define S_IFBLK 0060000 /* block special */
+ #define S_IFREG 0100000 /* regular */
+ #define S_IFLNK 0120000 /* symbolic link */
+ #define S_IFSOCK 0140000 /* socket */
+ #define S_ISUID 0004000 /* set-user-ID on execution */
+ #define S_ISGID 0002000 /* set-group-ID on execution */
+ #define S_ISVTX 0001000 /* save swapped text even after use */
+ #define S_IRWXU 0000700 /* RWX mask for owner */
+ #define S_IRUSR 0000400 /* R for owner */
+ #define S_IWUSR 0000200 /* W for owner */
+ #define S_IXUSR 0000100 /* X for owner */
+ #define S_IRWXG 0000070 /* RWX mask for group */
+ #define S_IRGRP 0000040 /* R for group */
+ #define S_IWGRP 0000020 /* W for group */
+ #define S_IXGRP 0000010 /* X for group */
+ #define S_IRWXO 0000007 /* RWX mask for other */
+ #define S_IROTH 0000004 /* R for other */
+ #define S_IWOTH 0000002 /* W for other */
+ #define S_IXOTH 0000001 /* X for other */
+
+ The following macros test a file's type. If the file is of that type, a
+ non-zero value is returned; otherwise, 0 is returned.
+
+ S_ISBLK(st_mode m) /* block special */
+ S_ISCHR(st_mode m) /* char special */
+ S_ISDIR(st_mode m) /* directory */
+ S_ISFIFO(st_mode m) /* fifo */
+ S_ISLNK(st_mode m) /* symbolic link */
+ S_ISREG(st_mode m) /* regular file */
+ S_ISSOCK(st_mode m) /* socket */
+
+ For a list of access modes, see <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh>, access(2), and chmod(2).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ Upon successful completion, the value 0 is returned; otherwise the
+ value -1 is returned and the global variable _\be_\br_\br_\bn_\bo is set to indicate the
+ error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ s\bst\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [ENOTDIR] A component of the path prefix is not a directory.
+
+ [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX
+ characters, or an entire pathname (including the
+ terminating NUL) exceeded PATH_MAX bytes.
+
+ [ENOENT] A component of _\bn_\ba_\bm_\be does not exist or _\bn_\ba_\bm_\be is the
+ empty path.
+
+ [EACCES] Search permission is denied for a component of the
+ path prefix.
+
+ [ELOOP] Too many symbolic links were encountered in
+ translating the pathname.
+
+ [EFAULT] _\bs_\bb or _\bn_\ba_\bm_\be points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from or writing to
+ the file system.
+
+ Additionally, f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [EINVAL] The value of the _\bf_\bl_\ba_\bg argument was neither zero nor
+ AT_SYMLINK_NOFOLLOW.
+
+ [EBADF] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is neither AT_FDCWD nor a valid file
+ descriptor.
+
+ [ENOTDIR] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is a valid file descriptor but it does not
+ reference a directory.
+
+ [EACCES] The _\bp_\ba_\bt_\bh argument specifies a relative path but search
+ permission is denied for the directory which the _\bf_\bd
+ file descriptor references.
+
+ f\bfs\bst\bta\bat\bt() will fail if:
+
+ [EBADF] _\bf_\bd is not a valid open file descriptor.
+
+ [EFAULT] _\bs_\bb points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from the file
+ system.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ chmod(2), chown(2), clock_gettime(2), utimes(2), symlink(7)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ Previous versions of the system used different types for the _\bs_\bt_\b__\bd_\be_\bv,
+ _\bs_\bt_\b__\bu_\bi_\bd, _\bs_\bt_\b__\bg_\bi_\bd, _\bs_\bt_\b__\br_\bd_\be_\bv, _\bs_\bt_\b__\bs_\bi_\bz_\be, _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be, and _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs fields.
+
+ The f\bfs\bst\bta\bat\bt(), f\bfs\bst\bta\bat\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and s\bst\bta\bat\bt() functions are intended to
+ conform to IEEE Std 1003.1-2008 (``POSIX.1'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The s\bst\bta\bat\bt() and f\bfs\bst\bta\bat\bt() system calls first appeared in Version 1 AT&T
+ UNIX. The <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> header file and the _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt were introduced
+ in Version 7 AT&T UNIX.
+
+ An l\bls\bst\bta\bat\bt() function call appeared in 4.2BSD. The f\bfs\bst\bta\bat\bta\bat\bt() function
+ appeared in OpenBSD 5.0.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ The file generation number, _\bs_\bt_\b__\bg_\be_\bn, is only available to the superuser.
+
+ Certain programs written when the timestamps were just of type time_t
+ assumed that the members were consecutive (and could therefore be treated
+ as an array and have their address passed directly to utime(3)). The
+ transition to timestamps of type struct timespec broke them irrevocably.
+
+B\bBU\bUG\bGS\bS
+ Applying f\bfs\bst\bta\bat\bt() to a pipe or socket fails to fill in a unique device and
+ inode number pair. Applying f\bfs\bst\bta\bat\bt() to a socket also fails to fill in
+ the time fields.
+
+N\bNA\bAM\bME\bE
+ s\bst\bta\bat\bt, l\bls\bst\bta\bat\bt, f\bfs\bst\bta\bat\bta\bat\bt, f\bfs\bst\bta\bat\bt - get file status
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ s\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ l\bls\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<f\bfc\bcn\bnt\btl\bl.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb, _\bi_\bn_\bt _\bf_\bl_\ba_\bg);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The s\bst\bta\bat\bt() function obtains information about the file pointed to by
+ _\bp_\ba_\bt_\bh. Read, write, or execute permission of the named file is not
+ required, but all directories listed in the path name leading to the file
+ must be searchable.
+
+ The l\bls\bst\bta\bat\bt() function is identical to s\bst\bta\bat\bt() except when the named file is
+ a symbolic link, in which case l\bls\bst\bta\bat\bt() returns information about the link
+ itself, not the file the link references.
+
+ The f\bfs\bst\bta\bat\bta\bat\bt() function is equivalent to either the s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt()
+ function depending on the value of _\bf_\bl_\ba_\bg (see below), except that where
+ _\bp_\ba_\bt_\bh specifies a relative path, the file whose information is returned is
+ determined relative to the directory associated with file descriptor _\bf_\bd
+ instead of the current working directory.
+
+ If f\bfs\bst\bta\bat\bta\bat\bt() is passed the special value AT_FDCWD (defined in <_\bf_\bc_\bn_\bt_\bl_\b._\bh>)
+ in the _\bf_\bd parameter, the current working directory is used and the
+ behavior is identical to a call to s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt(), depending on
+ whether or not the AT_SYMLINK_NOFOLLOW bit is set in _\bf_\bl_\ba_\bg.
+
+ The _\bf_\bl_\ba_\bg argument is the bitwise OR of zero or more of the following
+ values:
+
+ AT_SYMLINK_NOFOLLOW If _\bp_\ba_\bt_\bh names a symbolic link, then the status
+ of the symbolic link is returned.
+
+ The f\bfs\bst\bta\bat\bt() function obtains the same information about an open file
+ known by the file descriptor _\bf_\bd.
+
+ The _\bs_\bb argument is a pointer to a s\bst\bta\bat\bt() structure as defined by
+ <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> (shown below) and into which information is placed
+ concerning the file.
+
+ struct stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ blkcnt_t st_blocks; /* blocks allocated for file */
+ blksize_t st_blksize;/* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ };
+
+ The time-related fields of struct stat are represented in struct timespec
+ format, which has nanosecond precision. However, the actual precision is
+ generally limited by the file system holding the file. The fields are as
+ follows:
+
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm Time when file data was last accessed. Set when the file
+ system object was created and updated by the utimes(2) and
+ read(2) system calls.
+
+ _\bs_\bt_\b__\bm_\bt_\bi_\bm Time when file data was last modified. Changed by the
+ truncate(2), utimes(2), and write(2) system calls. For
+ directories, changed by any system call that alters which
+ files are in the directory, such as the unlink(2), rename(2),
+ mkdir(2), and symlink(2) system calls.
+
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm Time when file status was last changed (inode data
+ modification). Changed by the chmod(2), chown(2), link(2),
+ rename(2), unlink(2), utimes(2), and write(2) system calls.
+
+ In addition, all the time fields are set to the current time when a file
+ system object is first created by the mkdir(2), mkfifo(2), mknod(2),
+ open(2), and symlink(2) system calls.
+
+ For compatibility with previous standards, _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be, and
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be macros are provided that expand to the _\bt_\bv_\b__\bs_\be_\bc_\bs member of their
+ respective struct timespec member. Deprecated macros are also provided
+ for some transitional names: _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc,
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, and _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc
+
+ The size-related fields of the struct stat are as follows:
+
+ _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be The optimal I/O block size for the file.
+
+ _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs The actual number of blocks allocated for the file in
+ 512-byte units. As short symbolic links are stored in the
+ inode, this number may be zero.
+
+ The status information word _\bs_\bt_\b__\bm_\bo_\bd_\be has the following bits:
+
+ #define S_IFMT 0170000 /* type of file mask */
+ #define S_IFIFO 0010000 /* named pipe (fifo) */
+ #define S_IFCHR 0020000 /* character special */
+ #define S_IFDIR 0040000 /* directory */
+ #define S_IFBLK 0060000 /* block special */
+ #define S_IFREG 0100000 /* regular */
+ #define S_IFLNK 0120000 /* symbolic link */
+ #define S_IFSOCK 0140000 /* socket */
+ #define S_ISUID 0004000 /* set-user-ID on execution */
+ #define S_ISGID 0002000 /* set-group-ID on execution */
+ #define S_ISVTX 0001000 /* save swapped text even after use */
+ #define S_IRWXU 0000700 /* RWX mask for owner */
+ #define S_IRUSR 0000400 /* R for owner */
+ #define S_IWUSR 0000200 /* W for owner */
+ #define S_IXUSR 0000100 /* X for owner */
+ #define S_IRWXG 0000070 /* RWX mask for group */
+ #define S_IRGRP 0000040 /* R for group */
+ #define S_IWGRP 0000020 /* W for group */
+ #define S_IXGRP 0000010 /* X for group */
+ #define S_IRWXO 0000007 /* RWX mask for other */
+ #define S_IROTH 0000004 /* R for other */
+ #define S_IWOTH 0000002 /* W for other */
+ #define S_IXOTH 0000001 /* X for other */
+
+ The following macros test a file's type. If the file is of that type, a
+ non-zero value is returned; otherwise, 0 is returned.
+
+ S_ISBLK(st_mode m) /* block special */
+ S_ISCHR(st_mode m) /* char special */
+ S_ISDIR(st_mode m) /* directory */
+ S_ISFIFO(st_mode m) /* fifo */
+ S_ISLNK(st_mode m) /* symbolic link */
+ S_ISREG(st_mode m) /* regular file */
+ S_ISSOCK(st_mode m) /* socket */
+
+ For a list of access modes, see <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh>, access(2), and chmod(2).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ Upon successful completion, the value 0 is returned; otherwise the
+ value -1 is returned and the global variable _\be_\br_\br_\bn_\bo is set to indicate the
+ error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ s\bst\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [ENOTDIR] A component of the path prefix is not a directory.
+
+ [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX
+ characters, or an entire pathname (including the
+ terminating NUL) exceeded PATH_MAX bytes.
+
+ [ENOENT] A component of _\bn_\ba_\bm_\be does not exist or _\bn_\ba_\bm_\be is the
+ empty path.
+
+ [EACCES] Search permission is denied for a component of the
+ path prefix.
+
+ [ELOOP] Too many symbolic links were encountered in
+ translating the pathname.
+
+ [EFAULT] _\bs_\bb or _\bn_\ba_\bm_\be points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from or writing to
+ the file system.
+
+ Additionally, f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [EINVAL] The value of the _\bf_\bl_\ba_\bg argument was neither zero nor
+ AT_SYMLINK_NOFOLLOW.
+
+ [EBADF] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is neither AT_FDCWD nor a valid file
+ descriptor.
+
+ [ENOTDIR] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is a valid file descriptor but it does not
+ reference a directory.
+
+ [EACCES] The _\bp_\ba_\bt_\bh argument specifies a relative path but search
+ permission is denied for the directory which the _\bf_\bd
+ file descriptor references.
+
+ f\bfs\bst\bta\bat\bt() will fail if:
+
+ [EBADF] _\bf_\bd is not a valid open file descriptor.
+
+ [EFAULT] _\bs_\bb points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from the file
+ system.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ chmod(2), chown(2), clock_gettime(2), utimes(2), symlink(7)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ Previous versions of the system used different types for the _\bs_\bt_\b__\bd_\be_\bv,
+ _\bs_\bt_\b__\bu_\bi_\bd, _\bs_\bt_\b__\bg_\bi_\bd, _\bs_\bt_\b__\br_\bd_\be_\bv, _\bs_\bt_\b__\bs_\bi_\bz_\be, _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be, and _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs fields.
+
+ The f\bfs\bst\bta\bat\bt(), f\bfs\bst\bta\bat\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and s\bst\bta\bat\bt() functions are intended to
+ conform to IEEE Std 1003.1-2008 (``POSIX.1'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The s\bst\bta\bat\bt() and f\bfs\bst\bta\bat\bt() system calls first appeared in Version 1 AT&T
+ UNIX. The <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> header file and the _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt were introduced
+ in Version 7 AT&T UNIX.
+
+ An l\bls\bst\bta\bat\bt() function call appeared in 4.2BSD. The f\bfs\bst\bta\bat\bta\bat\bt() function
+ appeared in OpenBSD 5.0.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ The file generation number, _\bs_\bt_\b__\bg_\be_\bn, is only available to the superuser.
+
+ Certain programs written when the timestamps were just of type time_t
+ assumed that the members were consecutive (and could therefore be treated
+ as an array and have their address passed directly to utime(3)). The
+ transition to timestamps of type struct timespec broke them irrevocably.
+
+B\bBU\bUG\bGS\bS
+ Applying f\bfs\bst\bta\bat\bt() to a pipe or socket fails to fill in a unique device and
+ inode number pair. Applying f\bfs\bst\bta\bat\bt() to a socket also fails to fill in
+ the time fields.
+
+N\bNA\bAM\bME\bE
+ s\bst\bta\bat\bt, l\bls\bst\bta\bat\bt, f\bfs\bst\bta\bat\bta\bat\bt, f\bfs\bst\bta\bat\bt - get file status
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ s\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ l\bls\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<f\bfc\bcn\bnt\btl\bl.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb, _\bi_\bn_\bt _\bf_\bl_\ba_\bg);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The s\bst\bta\bat\bt() function obtains information about the file pointed to by
+ _\bp_\ba_\bt_\bh. Read, write, or execute permission of the named file is not
+ required, but all directories listed in the path name leading to the file
+ must be searchable.
+
+ The l\bls\bst\bta\bat\bt() function is identical to s\bst\bta\bat\bt() except when the named file is
+ a symbolic link, in which case l\bls\bst\bta\bat\bt() returns information about the link
+ itself, not the file the link references.
+
+ The f\bfs\bst\bta\bat\bta\bat\bt() function is equivalent to either the s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt()
+ function depending on the value of _\bf_\bl_\ba_\bg (see below), except that where
+ _\bp_\ba_\bt_\bh specifies a relative path, the file whose information is returned is
+ determined relative to the directory associated with file descriptor _\bf_\bd
+ instead of the current working directory.
+
+ If f\bfs\bst\bta\bat\bta\bat\bt() is passed the special value AT_FDCWD (defined in <_\bf_\bc_\bn_\bt_\bl_\b._\bh>)
+ in the _\bf_\bd parameter, the current working directory is used and the
+ behavior is identical to a call to s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt(), depending on
+ whether or not the AT_SYMLINK_NOFOLLOW bit is set in _\bf_\bl_\ba_\bg.
+
+ The _\bf_\bl_\ba_\bg argument is the bitwise OR of zero or more of the following
+ values:
+
+ AT_SYMLINK_NOFOLLOW If _\bp_\ba_\bt_\bh names a symbolic link, then the status
+ of the symbolic link is returned.
+
+ The f\bfs\bst\bta\bat\bt() function obtains the same information about an open file
+ known by the file descriptor _\bf_\bd.
+
+ The _\bs_\bb argument is a pointer to a s\bst\bta\bat\bt() structure as defined by
+ <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> (shown below) and into which information is placed
+ concerning the file.
+
+ struct stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ blkcnt_t st_blocks; /* blocks allocated for file */
+ blksize_t st_blksize;/* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ };
+
+ The time-related fields of struct stat are represented in struct timespec
+ format, which has nanosecond precision. However, the actual precision is
+ generally limited by the file system holding the file. The fields are as
+ follows:
+
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm Time when file data was last accessed. Set when the file
+ system object was created and updated by the utimes(2) and
+ read(2) system calls.
+
+ _\bs_\bt_\b__\bm_\bt_\bi_\bm Time when file data was last modified. Changed by the
+ truncate(2), utimes(2), and write(2) system calls. For
+ directories, changed by any system call that alters which
+ files are in the directory, such as the unlink(2), rename(2),
+ mkdir(2), and symlink(2) system calls.
+
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm Time when file status was last changed (inode data
+ modification). Changed by the chmod(2), chown(2), link(2),
+ rename(2), unlink(2), utimes(2), and write(2) system calls.
+
+ In addition, all the time fields are set to the current time when a file
+ system object is first created by the mkdir(2), mkfifo(2), mknod(2),
+ open(2), and symlink(2) system calls.
+
+ For compatibility with previous standards, _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be, and
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be macros are provided that expand to the _\bt_\bv_\b__\bs_\be_\bc_\bs member of their
+ respective struct timespec member. Deprecated macros are also provided
+ for some transitional names: _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc,
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, and _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc
+
+ The size-related fields of the struct stat are as follows:
+
+ _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be The optimal I/O block size for the file.
+
+ _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs The actual number of blocks allocated for the file in
+ 512-byte units. As short symbolic links are stored in the
+ inode, this number may be zero.
+
+ The status information word _\bs_\bt_\b__\bm_\bo_\bd_\be has the following bits:
+
+ #define S_IFMT 0170000 /* type of file mask */
+ #define S_IFIFO 0010000 /* named pipe (fifo) */
+ #define S_IFCHR 0020000 /* character special */
+ #define S_IFDIR 0040000 /* directory */
+ #define S_IFBLK 0060000 /* block special */
+ #define S_IFREG 0100000 /* regular */
+ #define S_IFLNK 0120000 /* symbolic link */
+ #define S_IFSOCK 0140000 /* socket */
+ #define S_ISUID 0004000 /* set-user-ID on execution */
+ #define S_ISGID 0002000 /* set-group-ID on execution */
+ #define S_ISVTX 0001000 /* save swapped text even after use */
+ #define S_IRWXU 0000700 /* RWX mask for owner */
+ #define S_IRUSR 0000400 /* R for owner */
+ #define S_IWUSR 0000200 /* W for owner */
+ #define S_IXUSR 0000100 /* X for owner */
+ #define S_IRWXG 0000070 /* RWX mask for group */
+ #define S_IRGRP 0000040 /* R for group */
+ #define S_IWGRP 0000020 /* W for group */
+ #define S_IXGRP 0000010 /* X for group */
+ #define S_IRWXO 0000007 /* RWX mask for other */
+ #define S_IROTH 0000004 /* R for other */
+ #define S_IWOTH 0000002 /* W for other */
+ #define S_IXOTH 0000001 /* X for other */
+
+ The following macros test a file's type. If the file is of that type, a
+ non-zero value is returned; otherwise, 0 is returned.
+
+ S_ISBLK(st_mode m) /* block special */
+ S_ISCHR(st_mode m) /* char special */
+ S_ISDIR(st_mode m) /* directory */
+ S_ISFIFO(st_mode m) /* fifo */
+ S_ISLNK(st_mode m) /* symbolic link */
+ S_ISREG(st_mode m) /* regular file */
+ S_ISSOCK(st_mode m) /* socket */
+
+ For a list of access modes, see <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh>, access(2), and chmod(2).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ Upon successful completion, the value 0 is returned; otherwise the
+ value -1 is returned and the global variable _\be_\br_\br_\bn_\bo is set to indicate the
+ error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ s\bst\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [ENOTDIR] A component of the path prefix is not a directory.
+
+ [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX
+ characters, or an entire pathname (including the
+ terminating NUL) exceeded PATH_MAX bytes.
+
+ [ENOENT] A component of _\bn_\ba_\bm_\be does not exist or _\bn_\ba_\bm_\be is the
+ empty path.
+
+ [EACCES] Search permission is denied for a component of the
+ path prefix.
+
+ [ELOOP] Too many symbolic links were encountered in
+ translating the pathname.
+
+ [EFAULT] _\bs_\bb or _\bn_\ba_\bm_\be points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from or writing to
+ the file system.
+
+ Additionally, f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [EINVAL] The value of the _\bf_\bl_\ba_\bg argument was neither zero nor
+ AT_SYMLINK_NOFOLLOW.
+
+ [EBADF] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is neither AT_FDCWD nor a valid file
+ descriptor.
+
+ [ENOTDIR] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is a valid file descriptor but it does not
+ reference a directory.
+
+ [EACCES] The _\bp_\ba_\bt_\bh argument specifies a relative path but search
+ permission is denied for the directory which the _\bf_\bd
+ file descriptor references.
+
+ f\bfs\bst\bta\bat\bt() will fail if:
+
+ [EBADF] _\bf_\bd is not a valid open file descriptor.
+
+ [EFAULT] _\bs_\bb points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from the file
+ system.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ chmod(2), chown(2), clock_gettime(2), utimes(2), symlink(7)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ Previous versions of the system used different types for the _\bs_\bt_\b__\bd_\be_\bv,
+ _\bs_\bt_\b__\bu_\bi_\bd, _\bs_\bt_\b__\bg_\bi_\bd, _\bs_\bt_\b__\br_\bd_\be_\bv, _\bs_\bt_\b__\bs_\bi_\bz_\be, _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be, and _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs fields.
+
+ The f\bfs\bst\bta\bat\bt(), f\bfs\bst\bta\bat\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and s\bst\bta\bat\bt() functions are intended to
+ conform to IEEE Std 1003.1-2008 (``POSIX.1'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The s\bst\bta\bat\bt() and f\bfs\bst\bta\bat\bt() system calls first appeared in Version 1 AT&T
+ UNIX. The <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> header file and the _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt were introduced
+ in Version 7 AT&T UNIX.
+
+ An l\bls\bst\bta\bat\bt() function call appeared in 4.2BSD. The f\bfs\bst\bta\bat\bta\bat\bt() function
+ appeared in OpenBSD 5.0.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ The file generation number, _\bs_\bt_\b__\bg_\be_\bn, is only available to the superuser.
+
+ Certain programs written when the timestamps were just of type time_t
+ assumed that the members were consecutive (and could therefore be treated
+ as an array and have their address passed directly to utime(3)). The
+ transition to timestamps of type struct timespec broke them irrevocably.
+
+B\bBU\bUG\bGS\bS
+ Applying f\bfs\bst\bta\bat\bt() to a pipe or socket fails to fill in a unique device and
+ inode number pair. Applying f\bfs\bst\bta\bat\bt() to a socket also fails to fill in
+ the time fields.
+
+N\bNA\bAM\bME\bE
+ s\bst\bta\bat\bt, l\bls\bst\bta\bat\bt, f\bfs\bst\bta\bat\bta\bat\bt, f\bfs\bst\bta\bat\bt - get file status
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ s\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ l\bls\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<f\bfc\bcn\bnt\btl\bl.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb, _\bi_\bn_\bt _\bf_\bl_\ba_\bg);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The s\bst\bta\bat\bt() function obtains information about the file pointed to by
+ _\bp_\ba_\bt_\bh. Read, write, or execute permission of the named file is not
+ required, but all directories listed in the path name leading to the file
+ must be searchable.
+
+ The l\bls\bst\bta\bat\bt() function is identical to s\bst\bta\bat\bt() except when the named file is
+ a symbolic link, in which case l\bls\bst\bta\bat\bt() returns information about the link
+ itself, not the file the link references.
+
+ The f\bfs\bst\bta\bat\bta\bat\bt() function is equivalent to either the s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt()
+ function depending on the value of _\bf_\bl_\ba_\bg (see below), except that where
+ _\bp_\ba_\bt_\bh specifies a relative path, the file whose information is returned is
+ determined relative to the directory associated with file descriptor _\bf_\bd
+ instead of the current working directory.
+
+ If f\bfs\bst\bta\bat\bta\bat\bt() is passed the special value AT_FDCWD (defined in <_\bf_\bc_\bn_\bt_\bl_\b._\bh>)
+ in the _\bf_\bd parameter, the current working directory is used and the
+ behavior is identical to a call to s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt(), depending on
+ whether or not the AT_SYMLINK_NOFOLLOW bit is set in _\bf_\bl_\ba_\bg.
+
+ The _\bf_\bl_\ba_\bg argument is the bitwise OR of zero or more of the following
+ values:
+
+ AT_SYMLINK_NOFOLLOW If _\bp_\ba_\bt_\bh names a symbolic link, then the status
+ of the symbolic link is returned.
+
+ The f\bfs\bst\bta\bat\bt() function obtains the same information about an open file
+ known by the file descriptor _\bf_\bd.
+
+ The _\bs_\bb argument is a pointer to a s\bst\bta\bat\bt() structure as defined by
+ <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> (shown below) and into which information is placed
+ concerning the file.
+
+ struct stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ blkcnt_t st_blocks; /* blocks allocated for file */
+ blksize_t st_blksize;/* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ };
+
+ The time-related fields of struct stat are represented in struct timespec
+ format, which has nanosecond precision. However, the actual precision is
+ generally limited by the file system holding the file. The fields are as
+ follows:
+
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm Time when file data was last accessed. Set when the file
+ system object was created and updated by the utimes(2) and
+ read(2) system calls.
+
+ _\bs_\bt_\b__\bm_\bt_\bi_\bm Time when file data was last modified. Changed by the
+ truncate(2), utimes(2), and write(2) system calls. For
+ directories, changed by any system call that alters which
+ files are in the directory, such as the unlink(2), rename(2),
+ mkdir(2), and symlink(2) system calls.
+
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm Time when file status was last changed (inode data
+ modification). Changed by the chmod(2), chown(2), link(2),
+ rename(2), unlink(2), utimes(2), and write(2) system calls.
+
+ In addition, all the time fields are set to the current time when a file
+ system object is first created by the mkdir(2), mkfifo(2), mknod(2),
+ open(2), and symlink(2) system calls.
+
+ For compatibility with previous standards, _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be, and
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be macros are provided that expand to the _\bt_\bv_\b__\bs_\be_\bc_\bs member of their
+ respective struct timespec member. Deprecated macros are also provided
+ for some transitional names: _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc,
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, and _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc
+
+ The size-related fields of the struct stat are as follows:
+
+ _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be The optimal I/O block size for the file.
+
+ _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs The actual number of blocks allocated for the file in
+ 512-byte units. As short symbolic links are stored in the
+ inode, this number may be zero.
+
+ The status information word _\bs_\bt_\b__\bm_\bo_\bd_\be has the following bits:
+
+ #define S_IFMT 0170000 /* type of file mask */
+ #define S_IFIFO 0010000 /* named pipe (fifo) */
+ #define S_IFCHR 0020000 /* character special */
+ #define S_IFDIR 0040000 /* directory */
+ #define S_IFBLK 0060000 /* block special */
+ #define S_IFREG 0100000 /* regular */
+ #define S_IFLNK 0120000 /* symbolic link */
+ #define S_IFSOCK 0140000 /* socket */
+ #define S_ISUID 0004000 /* set-user-ID on execution */
+ #define S_ISGID 0002000 /* set-group-ID on execution */
+ #define S_ISVTX 0001000 /* save swapped text even after use */
+ #define S_IRWXU 0000700 /* RWX mask for owner */
+ #define S_IRUSR 0000400 /* R for owner */
+ #define S_IWUSR 0000200 /* W for owner */
+ #define S_IXUSR 0000100 /* X for owner */
+ #define S_IRWXG 0000070 /* RWX mask for group */
+ #define S_IRGRP 0000040 /* R for group */
+ #define S_IWGRP 0000020 /* W for group */
+ #define S_IXGRP 0000010 /* X for group */
+ #define S_IRWXO 0000007 /* RWX mask for other */
+ #define S_IROTH 0000004 /* R for other */
+ #define S_IWOTH 0000002 /* W for other */
+ #define S_IXOTH 0000001 /* X for other */
+
+ The following macros test a file's type. If the file is of that type, a
+ non-zero value is returned; otherwise, 0 is returned.
+
+ S_ISBLK(st_mode m) /* block special */
+ S_ISCHR(st_mode m) /* char special */
+ S_ISDIR(st_mode m) /* directory */
+ S_ISFIFO(st_mode m) /* fifo */
+ S_ISLNK(st_mode m) /* symbolic link */
+ S_ISREG(st_mode m) /* regular file */
+ S_ISSOCK(st_mode m) /* socket */
+
+ For a list of access modes, see <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh>, access(2), and chmod(2).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ Upon successful completion, the value 0 is returned; otherwise the
+ value -1 is returned and the global variable _\be_\br_\br_\bn_\bo is set to indicate the
+ error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ s\bst\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [ENOTDIR] A component of the path prefix is not a directory.
+
+ [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX
+ characters, or an entire pathname (including the
+ terminating NUL) exceeded PATH_MAX bytes.
+
+ [ENOENT] A component of _\bn_\ba_\bm_\be does not exist or _\bn_\ba_\bm_\be is the
+ empty path.
+
+ [EACCES] Search permission is denied for a component of the
+ path prefix.
+
+ [ELOOP] Too many symbolic links were encountered in
+ translating the pathname.
+
+ [EFAULT] _\bs_\bb or _\bn_\ba_\bm_\be points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from or writing to
+ the file system.
+
+ Additionally, f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [EINVAL] The value of the _\bf_\bl_\ba_\bg argument was neither zero nor
+ AT_SYMLINK_NOFOLLOW.
+
+ [EBADF] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is neither AT_FDCWD nor a valid file
+ descriptor.
+
+ [ENOTDIR] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is a valid file descriptor but it does not
+ reference a directory.
+
+ [EACCES] The _\bp_\ba_\bt_\bh argument specifies a relative path but search
+ permission is denied for the directory which the _\bf_\bd
+ file descriptor references.
+
+ f\bfs\bst\bta\bat\bt() will fail if:
+
+ [EBADF] _\bf_\bd is not a valid open file descriptor.
+
+ [EFAULT] _\bs_\bb points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from the file
+ system.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ chmod(2), chown(2), clock_gettime(2), utimes(2), symlink(7)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ Previous versions of the system used different types for the _\bs_\bt_\b__\bd_\be_\bv,
+ _\bs_\bt_\b__\bu_\bi_\bd, _\bs_\bt_\b__\bg_\bi_\bd, _\bs_\bt_\b__\br_\bd_\be_\bv, _\bs_\bt_\b__\bs_\bi_\bz_\be, _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be, and _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs fields.
+
+ The f\bfs\bst\bta\bat\bt(), f\bfs\bst\bta\bat\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and s\bst\bta\bat\bt() functions are intended to
+ conform to IEEE Std 1003.1-2008 (``POSIX.1'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The s\bst\bta\bat\bt() and f\bfs\bst\bta\bat\bt() system calls first appeared in Version 1 AT&T
+ UNIX. The <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> header file and the _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt were introduced
+ in Version 7 AT&T UNIX.
+
+ An l\bls\bst\bta\bat\bt() function call appeared in 4.2BSD. The f\bfs\bst\bta\bat\bta\bat\bt() function
+ appeared in OpenBSD 5.0.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ The file generation number, _\bs_\bt_\b__\bg_\be_\bn, is only available to the superuser.
+
+ Certain programs written when the timestamps were just of type time_t
+ assumed that the members were consecutive (and could therefore be treated
+ as an array and have their address passed directly to utime(3)). The
+ transition to timestamps of type struct timespec broke them irrevocably.
+
+B\bBU\bUG\bGS\bS
+ Applying f\bfs\bst\bta\bat\bt() to a pipe or socket fails to fill in a unique device and
+ inode number pair. Applying f\bfs\bst\bta\bat\bt() to a socket also fails to fill in
+ the time fields.
+
+N\bNA\bAM\bME\bE
+ s\bst\bta\bat\bt, l\bls\bst\bta\bat\bt, f\bfs\bst\bta\bat\bta\bat\bt, f\bfs\bst\bta\bat\bt - get file status
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ s\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ l\bls\bst\bta\bat\bt(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bst\bta\bat\bt.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<f\bfc\bcn\bnt\btl\bl.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ f\bfs\bst\bta\bat\bta\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt _\b*_\bs_\bb, _\bi_\bn_\bt _\bf_\bl_\ba_\bg);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The s\bst\bta\bat\bt() function obtains information about the file pointed to by
+ _\bp_\ba_\bt_\bh. Read, write, or execute permission of the named file is not
+ required, but all directories listed in the path name leading to the file
+ must be searchable.
+
+ The l\bls\bst\bta\bat\bt() function is identical to s\bst\bta\bat\bt() except when the named file is
+ a symbolic link, in which case l\bls\bst\bta\bat\bt() returns information about the link
+ itself, not the file the link references.
+
+ The f\bfs\bst\bta\bat\bta\bat\bt() function is equivalent to either the s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt()
+ function depending on the value of _\bf_\bl_\ba_\bg (see below), except that where
+ _\bp_\ba_\bt_\bh specifies a relative path, the file whose information is returned is
+ determined relative to the directory associated with file descriptor _\bf_\bd
+ instead of the current working directory.
+
+ If f\bfs\bst\bta\bat\bta\bat\bt() is passed the special value AT_FDCWD (defined in <_\bf_\bc_\bn_\bt_\bl_\b._\bh>)
+ in the _\bf_\bd parameter, the current working directory is used and the
+ behavior is identical to a call to s\bst\bta\bat\bt() or l\bls\bst\bta\bat\bt(), depending on
+ whether or not the AT_SYMLINK_NOFOLLOW bit is set in _\bf_\bl_\ba_\bg.
+
+ The _\bf_\bl_\ba_\bg argument is the bitwise OR of zero or more of the following
+ values:
+
+ AT_SYMLINK_NOFOLLOW If _\bp_\ba_\bt_\bh names a symbolic link, then the status
+ of the symbolic link is returned.
+
+ The f\bfs\bst\bta\bat\bt() function obtains the same information about an open file
+ known by the file descriptor _\bf_\bd.
+
+ The _\bs_\bb argument is a pointer to a s\bst\bta\bat\bt() structure as defined by
+ <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> (shown below) and into which information is placed
+ concerning the file.
+
+ struct stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ struct timespec st_atim; /* time of last access */
+ struct timespec st_mtim; /* time of last data modification */
+ struct timespec st_ctim; /* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ blkcnt_t st_blocks; /* blocks allocated for file */
+ blksize_t st_blksize;/* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ };
+
+ The time-related fields of struct stat are represented in struct timespec
+ format, which has nanosecond precision. However, the actual precision is
+ generally limited by the file system holding the file. The fields are as
+ follows:
+
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm Time when file data was last accessed. Set when the file
+ system object was created and updated by the utimes(2) and
+ read(2) system calls.
+
+ _\bs_\bt_\b__\bm_\bt_\bi_\bm Time when file data was last modified. Changed by the
+ truncate(2), utimes(2), and write(2) system calls. For
+ directories, changed by any system call that alters which
+ files are in the directory, such as the unlink(2), rename(2),
+ mkdir(2), and symlink(2) system calls.
+
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm Time when file status was last changed (inode data
+ modification). Changed by the chmod(2), chown(2), link(2),
+ rename(2), unlink(2), utimes(2), and write(2) system calls.
+
+ In addition, all the time fields are set to the current time when a file
+ system object is first created by the mkdir(2), mkfifo(2), mknod(2),
+ open(2), and symlink(2) system calls.
+
+ For compatibility with previous standards, _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be, and
+ _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be macros are provided that expand to the _\bt_\bv_\b__\bs_\be_\bc_\bs member of their
+ respective struct timespec member. Deprecated macros are also provided
+ for some transitional names: _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc, _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bn_\bs_\be_\bc,
+ _\bs_\bt_\b__\ba_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, _\bs_\bt_\b__\bm_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc, and _\bs_\bt_\b__\bc_\bt_\bi_\bm_\be_\bs_\bp_\be_\bc
+
+ The size-related fields of the struct stat are as follows:
+
+ _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be The optimal I/O block size for the file.
+
+ _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs The actual number of blocks allocated for the file in
+ 512-byte units. As short symbolic links are stored in the
+ inode, this number may be zero.
+
+ The status information word _\bs_\bt_\b__\bm_\bo_\bd_\be has the following bits:
+
+ #define S_IFMT 0170000 /* type of file mask */
+ #define S_IFIFO 0010000 /* named pipe (fifo) */
+ #define S_IFCHR 0020000 /* character special */
+ #define S_IFDIR 0040000 /* directory */
+ #define S_IFBLK 0060000 /* block special */
+ #define S_IFREG 0100000 /* regular */
+ #define S_IFLNK 0120000 /* symbolic link */
+ #define S_IFSOCK 0140000 /* socket */
+ #define S_ISUID 0004000 /* set-user-ID on execution */
+ #define S_ISGID 0002000 /* set-group-ID on execution */
+ #define S_ISVTX 0001000 /* save swapped text even after use */
+ #define S_IRWXU 0000700 /* RWX mask for owner */
+ #define S_IRUSR 0000400 /* R for owner */
+ #define S_IWUSR 0000200 /* W for owner */
+ #define S_IXUSR 0000100 /* X for owner */
+ #define S_IRWXG 0000070 /* RWX mask for group */
+ #define S_IRGRP 0000040 /* R for group */
+ #define S_IWGRP 0000020 /* W for group */
+ #define S_IXGRP 0000010 /* X for group */
+ #define S_IRWXO 0000007 /* RWX mask for other */
+ #define S_IROTH 0000004 /* R for other */
+ #define S_IWOTH 0000002 /* W for other */
+ #define S_IXOTH 0000001 /* X for other */
+
+ The following macros test a file's type. If the file is of that type, a
+ non-zero value is returned; otherwise, 0 is returned.
+
+ S_ISBLK(st_mode m) /* block special */
+ S_ISCHR(st_mode m) /* char special */
+ S_ISDIR(st_mode m) /* directory */
+ S_ISFIFO(st_mode m) /* fifo */
+ S_ISLNK(st_mode m) /* symbolic link */
+ S_ISREG(st_mode m) /* regular file */
+ S_ISSOCK(st_mode m) /* socket */
+
+ For a list of access modes, see <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh>, access(2), and chmod(2).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ Upon successful completion, the value 0 is returned; otherwise the
+ value -1 is returned and the global variable _\be_\br_\br_\bn_\bo is set to indicate the
+ error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ s\bst\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [ENOTDIR] A component of the path prefix is not a directory.
+
+ [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX
+ characters, or an entire pathname (including the
+ terminating NUL) exceeded PATH_MAX bytes.
+
+ [ENOENT] A component of _\bn_\ba_\bm_\be does not exist or _\bn_\ba_\bm_\be is the
+ empty path.
+
+ [EACCES] Search permission is denied for a component of the
+ path prefix.
+
+ [ELOOP] Too many symbolic links were encountered in
+ translating the pathname.
+
+ [EFAULT] _\bs_\bb or _\bn_\ba_\bm_\be points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from or writing to
+ the file system.
+
+ Additionally, f\bfs\bst\bta\bat\bta\bat\bt() will fail if:
+
+ [EINVAL] The value of the _\bf_\bl_\ba_\bg argument was neither zero nor
+ AT_SYMLINK_NOFOLLOW.
+
+ [EBADF] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is neither AT_FDCWD nor a valid file
+ descriptor.
+
+ [ENOTDIR] The _\bp_\ba_\bt_\bh argument specifies a relative path and the _\bf_\bd
+ argument is a valid file descriptor but it does not
+ reference a directory.
+
+ [EACCES] The _\bp_\ba_\bt_\bh argument specifies a relative path but search
+ permission is denied for the directory which the _\bf_\bd
+ file descriptor references.
+
+ f\bfs\bst\bta\bat\bt() will fail if:
+
+ [EBADF] _\bf_\bd is not a valid open file descriptor.
+
+ [EFAULT] _\bs_\bb points to an invalid address.
+
+ [EIO] An I/O error occurred while reading from the file
+ system.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ chmod(2), chown(2), clock_gettime(2), utimes(2), symlink(7)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ Previous versions of the system used different types for the _\bs_\bt_\b__\bd_\be_\bv,
+ _\bs_\bt_\b__\bu_\bi_\bd, _\bs_\bt_\b__\bg_\bi_\bd, _\bs_\bt_\b__\br_\bd_\be_\bv, _\bs_\bt_\b__\bs_\bi_\bz_\be, _\bs_\bt_\b__\bb_\bl_\bk_\bs_\bi_\bz_\be, and _\bs_\bt_\b__\bb_\bl_\bo_\bc_\bk_\bs fields.
+
+ The f\bfs\bst\bta\bat\bt(), f\bfs\bst\bta\bat\bta\bat\bt(), l\bls\bst\bta\bat\bt(), and s\bst\bta\bat\bt() functions are intended to
+ conform to IEEE Std 1003.1-2008 (``POSIX.1'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The s\bst\bta\bat\bt() and f\bfs\bst\bta\bat\bt() system calls first appeared in Version 1 AT&T
+ UNIX. The <_\bs_\by_\bs_\b/_\bs_\bt_\ba_\bt_\b._\bh> header file and the _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bt_\ba_\bt were introduced
+ in Version 7 AT&T UNIX.
+
+ An l\bls\bst\bta\bat\bt() function call appeared in 4.2BSD. The f\bfs\bst\bta\bat\bta\bat\bt() function
+ appeared in OpenBSD 5.0.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ The file generation number, _\bs_\bt_\b__\bg_\be_\bn, is only available to the superuser.
+
+ Certain programs written when the timestamps were just of type time_t
+ assumed that the members were consecutive (and could therefore be treated
+ as an array and have their address passed directly to utime(3)). The
+ transition to timestamps of type struct timespec broke them irrevocably.
+
+B\bBU\bUG\bGS\bS
+ Applying f\bfs\bst\bta\bat\bt() to a pipe or socket fails to fill in a unique device and
+ inode number pair. Applying f\bfs\bst\bta\bat\bt() to a socket also fails to fill in
+ the time fields.
+
+N\bNA\bAM\bME\bE
+ w\bwa\bai\bit\bt, w\bwa\bai\bit\btp\bpi\bid\bd, w\bwa\bai\bit\bt4\b4, w\bwa\bai\bit\bt3\b3 - wait for process termination
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\btp\bpi\bid\bd(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt3\b3(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt4\b4(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The w\bwa\bai\bit\bt() function suspends execution of its calling process until
+ _\bs_\bt_\ba_\bt_\bu_\bs information is available for a terminated child process, or a
+ signal is received. On return from a successful w\bwa\bai\bit\bt() call, the _\bs_\bt_\ba_\bt_\bu_\bs
+ area, if non-zero, is filled in with termination information about the
+ process that exited (see below).
+
+ The w\bwa\bai\bit\bt4\b4() call provides a more general interface for programs that need
+ to wait for certain child processes, that need resource utilization
+ statistics accumulated by child processes, or that require options. The
+ other wait functions are implemented using w\bwa\bai\bit\bt4\b4().
+
+ The _\bw_\bp_\bi_\bd parameter specifies the set of child processes for which to
+ wait. The following symbolic constants are currently defined in
+ <_\bs_\by_\bs_\b/_\bw_\ba_\bi_\bt_\b._\bh>:
+
+ #define WAIT_ANY (-1) /* any process */
+ #define WAIT_MYPGRP 0 /* any process in my process group */
+
+ If _\bw_\bp_\bi_\bd is set to WAIT_ANY, the call waits for any child process. If
+ _\bw_\bp_\bi_\bd is set to WAIT_MYPGRP, the call waits for any child process in the
+ process group of the caller. If _\bw_\bp_\bi_\bd is greater than zero, the call
+ waits for the process with process ID _\bw_\bp_\bi_\bd. If _\bw_\bp_\bi_\bd is less than -1, the
+ call waits for any process whose process group ID equals the absolute
+ value of _\bw_\bp_\bi_\bd.
+
+ The _\bs_\bt_\ba_\bt_\bu_\bs parameter is defined below. The _\bo_\bp_\bt_\bi_\bo_\bn_\bs argument is the
+ bitwise OR of zero or more of the following values:
+
+ WCONTINUED Causes status to be reported for stopped child processes that
+ have been continued by receipt of a SIGCONT signal.
+
+ WNOHANG Indicates that the call should not block if there are no
+ processes that wish to report status.
+
+ WUNTRACED If set, children of the current process that are stopped due
+ to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal also have
+ their status reported.
+
+ If _\br_\bu_\bs_\ba_\bg_\be is non-zero, a summary of the resources used by the terminated
+ process and all its children is returned (this information is currently
+ not available for stopped processes).
+
+ When the WNOHANG option is specified and no processes wish to report
+ status, w\bwa\bai\bit\bt4\b4() returns a process ID of 0.
+
+ The w\bwa\bai\bit\btp\bpi\bid\bd() call is identical to w\bwa\bai\bit\bt4\b4() with an _\br_\bu_\bs_\ba_\bg_\be value of zero.
+ The older w\bwa\bai\bit\bt3\b3() call is the same as w\bwa\bai\bit\bt4\b4() with a _\bw_\bp_\bi_\bd value of -1.
+
+ The following macros may be used to test the manner of exit of the
+ process. One of the first three macros will evaluate to a non-zero
+ (true) value:
+
+ W\bWI\bIF\bFC\bCO\bON\bNT\bTI\bIN\bNU\bUE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, and has continued after a
+ job control stop. This macro can be true only if the wait call
+ specified the WCONTINUED option.
+
+ W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated normally by a call to _exit(2) or
+ exit(3).
+
+ W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated due to receipt of a signal.
+
+ W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, but has stopped and can
+ be restarted. This macro can be true only if the wait call
+ specified the WUNTRACED option or if the child process is being
+ traced (see ptrace(2)).
+
+ Depending on the values of those macros, the following macros produce the
+ remaining status information about the child process:
+
+ W\bWE\bEX\bXI\bIT\bTS\bST\bTA\bAT\bTU\bUS\bS(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the low-order 8 bits
+ of the argument passed to _exit(2) or exit(3) by the child.
+
+ W\bWT\bTE\bER\bRM\bMS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the termination of the process.
+
+ W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates as true if the
+ termination of the process was accompanied by the creation of a
+ core file containing an image of the process when the signal was
+ received.
+
+ W\bWS\bST\bTO\bOP\bPS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the process to stop.
+
+N\bNO\bOT\bTE\bES\bS
+ See sigaction(2) for a list of termination signals. A status of 0
+ indicates normal termination.
+
+ If a parent process terminates without waiting for all of its child
+ processes to terminate, the remaining child processes are assigned the
+ parent process 1 ID (the init process ID).
+
+ If a signal is caught while any of the w\bwa\bai\bit\bt() calls is pending, the call
+ may be interrupted or restarted when the signal-catching routine returns,
+ depending on the options in effect for the signal; for further
+ information, see siginterrupt(3).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If w\bwa\bai\bit\bt() returns due to a stopped or terminated child process, the
+ process ID of the child is returned to the calling process. Otherwise, a
+ value of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+ If w\bwa\bai\bit\bt4\b4(), w\bwa\bai\bit\bt3\b3() or w\bwa\bai\bit\btp\bpi\bid\bd() returns due to a stopped or terminated
+ child process, the process ID of the child is returned to the calling
+ process. If there are no children not previously awaited, -1 is returned
+ with _\be_\br_\br_\bn_\bo set to [ECHILD]. Otherwise, if WNOHANG is specified and there
+ are no stopped or exited children, 0 is returned. If an error is
+ detected or a caught signal aborts the call, a value of -1 is returned
+ and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ w\bwa\bai\bit\bt() will fail and return immediately if:
+
+ [ECHILD] The calling process has no existing unwaited-for child
+ processes.
+
+ [EFAULT] The _\bs_\bt_\ba_\bt_\bu_\bs or _\br_\bu_\bs_\ba_\bg_\be arguments point to an illegal
+ address. (May not be detected before exit of a child
+ process.)
+
+ [EINTR] The call was interrupted by a caught signal, or the
+ signal did not have the SA_RESTART flag set.
+
+ [EINVAL] Invalid or undefined flags were passed in the _\bo_\bp_\bt_\bi_\bo_\bn_\bs
+ argument.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ _exit(2), sigaction(2), exit(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The w\bwa\bai\bit\bt() and w\bwa\bai\bit\btp\bpi\bid\bd() functions conform to IEEE Std 1003.1-2008
+ (``POSIX.1'').
+
+ w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\bt3\b3() are not specified by POSIX. The W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP() macro
+ and the ability to restart a pending w\bwa\bai\bit\bt() call are extensions to that
+ specification.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A w\bwa\bai\bit\bt() system call first appeared in Version 1 AT&T UNIX. The _\bs_\bt_\ba_\bt_\bu_\bs
+ argument is accepted since Version 2 AT&T UNIX. A w\bwa\bai\bit\bt3\b3() system call
+ first appeared in 4BSD, but the final calling convention was only
+ established in 4.2BSD. The w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\btp\bpi\bid\bd() function calls first
+ appeared in 4.3BSD-Reno.
+
+N\bNA\bAM\bME\bE
+ w\bwa\bai\bit\bt, w\bwa\bai\bit\btp\bpi\bid\bd, w\bwa\bai\bit\bt4\b4, w\bwa\bai\bit\bt3\b3 - wait for process termination
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\btp\bpi\bid\bd(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt3\b3(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt4\b4(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The w\bwa\bai\bit\bt() function suspends execution of its calling process until
+ _\bs_\bt_\ba_\bt_\bu_\bs information is available for a terminated child process, or a
+ signal is received. On return from a successful w\bwa\bai\bit\bt() call, the _\bs_\bt_\ba_\bt_\bu_\bs
+ area, if non-zero, is filled in with termination information about the
+ process that exited (see below).
+
+ The w\bwa\bai\bit\bt4\b4() call provides a more general interface for programs that need
+ to wait for certain child processes, that need resource utilization
+ statistics accumulated by child processes, or that require options. The
+ other wait functions are implemented using w\bwa\bai\bit\bt4\b4().
+
+ The _\bw_\bp_\bi_\bd parameter specifies the set of child processes for which to
+ wait. The following symbolic constants are currently defined in
+ <_\bs_\by_\bs_\b/_\bw_\ba_\bi_\bt_\b._\bh>:
+
+ #define WAIT_ANY (-1) /* any process */
+ #define WAIT_MYPGRP 0 /* any process in my process group */
+
+ If _\bw_\bp_\bi_\bd is set to WAIT_ANY, the call waits for any child process. If
+ _\bw_\bp_\bi_\bd is set to WAIT_MYPGRP, the call waits for any child process in the
+ process group of the caller. If _\bw_\bp_\bi_\bd is greater than zero, the call
+ waits for the process with process ID _\bw_\bp_\bi_\bd. If _\bw_\bp_\bi_\bd is less than -1, the
+ call waits for any process whose process group ID equals the absolute
+ value of _\bw_\bp_\bi_\bd.
+
+ The _\bs_\bt_\ba_\bt_\bu_\bs parameter is defined below. The _\bo_\bp_\bt_\bi_\bo_\bn_\bs argument is the
+ bitwise OR of zero or more of the following values:
+
+ WCONTINUED Causes status to be reported for stopped child processes that
+ have been continued by receipt of a SIGCONT signal.
+
+ WNOHANG Indicates that the call should not block if there are no
+ processes that wish to report status.
+
+ WUNTRACED If set, children of the current process that are stopped due
+ to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal also have
+ their status reported.
+
+ If _\br_\bu_\bs_\ba_\bg_\be is non-zero, a summary of the resources used by the terminated
+ process and all its children is returned (this information is currently
+ not available for stopped processes).
+
+ When the WNOHANG option is specified and no processes wish to report
+ status, w\bwa\bai\bit\bt4\b4() returns a process ID of 0.
+
+ The w\bwa\bai\bit\btp\bpi\bid\bd() call is identical to w\bwa\bai\bit\bt4\b4() with an _\br_\bu_\bs_\ba_\bg_\be value of zero.
+ The older w\bwa\bai\bit\bt3\b3() call is the same as w\bwa\bai\bit\bt4\b4() with a _\bw_\bp_\bi_\bd value of -1.
+
+ The following macros may be used to test the manner of exit of the
+ process. One of the first three macros will evaluate to a non-zero
+ (true) value:
+
+ W\bWI\bIF\bFC\bCO\bON\bNT\bTI\bIN\bNU\bUE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, and has continued after a
+ job control stop. This macro can be true only if the wait call
+ specified the WCONTINUED option.
+
+ W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated normally by a call to _exit(2) or
+ exit(3).
+
+ W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated due to receipt of a signal.
+
+ W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, but has stopped and can
+ be restarted. This macro can be true only if the wait call
+ specified the WUNTRACED option or if the child process is being
+ traced (see ptrace(2)).
+
+ Depending on the values of those macros, the following macros produce the
+ remaining status information about the child process:
+
+ W\bWE\bEX\bXI\bIT\bTS\bST\bTA\bAT\bTU\bUS\bS(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the low-order 8 bits
+ of the argument passed to _exit(2) or exit(3) by the child.
+
+ W\bWT\bTE\bER\bRM\bMS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the termination of the process.
+
+ W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates as true if the
+ termination of the process was accompanied by the creation of a
+ core file containing an image of the process when the signal was
+ received.
+
+ W\bWS\bST\bTO\bOP\bPS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the process to stop.
+
+N\bNO\bOT\bTE\bES\bS
+ See sigaction(2) for a list of termination signals. A status of 0
+ indicates normal termination.
+
+ If a parent process terminates without waiting for all of its child
+ processes to terminate, the remaining child processes are assigned the
+ parent process 1 ID (the init process ID).
+
+ If a signal is caught while any of the w\bwa\bai\bit\bt() calls is pending, the call
+ may be interrupted or restarted when the signal-catching routine returns,
+ depending on the options in effect for the signal; for further
+ information, see siginterrupt(3).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If w\bwa\bai\bit\bt() returns due to a stopped or terminated child process, the
+ process ID of the child is returned to the calling process. Otherwise, a
+ value of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+ If w\bwa\bai\bit\bt4\b4(), w\bwa\bai\bit\bt3\b3() or w\bwa\bai\bit\btp\bpi\bid\bd() returns due to a stopped or terminated
+ child process, the process ID of the child is returned to the calling
+ process. If there are no children not previously awaited, -1 is returned
+ with _\be_\br_\br_\bn_\bo set to [ECHILD]. Otherwise, if WNOHANG is specified and there
+ are no stopped or exited children, 0 is returned. If an error is
+ detected or a caught signal aborts the call, a value of -1 is returned
+ and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ w\bwa\bai\bit\bt() will fail and return immediately if:
+
+ [ECHILD] The calling process has no existing unwaited-for child
+ processes.
+
+ [EFAULT] The _\bs_\bt_\ba_\bt_\bu_\bs or _\br_\bu_\bs_\ba_\bg_\be arguments point to an illegal
+ address. (May not be detected before exit of a child
+ process.)
+
+ [EINTR] The call was interrupted by a caught signal, or the
+ signal did not have the SA_RESTART flag set.
+
+ [EINVAL] Invalid or undefined flags were passed in the _\bo_\bp_\bt_\bi_\bo_\bn_\bs
+ argument.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ _exit(2), sigaction(2), exit(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The w\bwa\bai\bit\bt() and w\bwa\bai\bit\btp\bpi\bid\bd() functions conform to IEEE Std 1003.1-2008
+ (``POSIX.1'').
+
+ w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\bt3\b3() are not specified by POSIX. The W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP() macro
+ and the ability to restart a pending w\bwa\bai\bit\bt() call are extensions to that
+ specification.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A w\bwa\bai\bit\bt() system call first appeared in Version 1 AT&T UNIX. The _\bs_\bt_\ba_\bt_\bu_\bs
+ argument is accepted since Version 2 AT&T UNIX. A w\bwa\bai\bit\bt3\b3() system call
+ first appeared in 4BSD, but the final calling convention was only
+ established in 4.2BSD. The w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\btp\bpi\bid\bd() function calls first
+ appeared in 4.3BSD-Reno.
+
+N\bNA\bAM\bME\bE
+ w\bwa\bai\bit\bt, w\bwa\bai\bit\btp\bpi\bid\bd, w\bwa\bai\bit\bt4\b4, w\bwa\bai\bit\bt3\b3 - wait for process termination
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\btp\bpi\bid\bd(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt3\b3(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt4\b4(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The w\bwa\bai\bit\bt() function suspends execution of its calling process until
+ _\bs_\bt_\ba_\bt_\bu_\bs information is available for a terminated child process, or a
+ signal is received. On return from a successful w\bwa\bai\bit\bt() call, the _\bs_\bt_\ba_\bt_\bu_\bs
+ area, if non-zero, is filled in with termination information about the
+ process that exited (see below).
+
+ The w\bwa\bai\bit\bt4\b4() call provides a more general interface for programs that need
+ to wait for certain child processes, that need resource utilization
+ statistics accumulated by child processes, or that require options. The
+ other wait functions are implemented using w\bwa\bai\bit\bt4\b4().
+
+ The _\bw_\bp_\bi_\bd parameter specifies the set of child processes for which to
+ wait. The following symbolic constants are currently defined in
+ <_\bs_\by_\bs_\b/_\bw_\ba_\bi_\bt_\b._\bh>:
+
+ #define WAIT_ANY (-1) /* any process */
+ #define WAIT_MYPGRP 0 /* any process in my process group */
+
+ If _\bw_\bp_\bi_\bd is set to WAIT_ANY, the call waits for any child process. If
+ _\bw_\bp_\bi_\bd is set to WAIT_MYPGRP, the call waits for any child process in the
+ process group of the caller. If _\bw_\bp_\bi_\bd is greater than zero, the call
+ waits for the process with process ID _\bw_\bp_\bi_\bd. If _\bw_\bp_\bi_\bd is less than -1, the
+ call waits for any process whose process group ID equals the absolute
+ value of _\bw_\bp_\bi_\bd.
+
+ The _\bs_\bt_\ba_\bt_\bu_\bs parameter is defined below. The _\bo_\bp_\bt_\bi_\bo_\bn_\bs argument is the
+ bitwise OR of zero or more of the following values:
+
+ WCONTINUED Causes status to be reported for stopped child processes that
+ have been continued by receipt of a SIGCONT signal.
+
+ WNOHANG Indicates that the call should not block if there are no
+ processes that wish to report status.
+
+ WUNTRACED If set, children of the current process that are stopped due
+ to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal also have
+ their status reported.
+
+ If _\br_\bu_\bs_\ba_\bg_\be is non-zero, a summary of the resources used by the terminated
+ process and all its children is returned (this information is currently
+ not available for stopped processes).
+
+ When the WNOHANG option is specified and no processes wish to report
+ status, w\bwa\bai\bit\bt4\b4() returns a process ID of 0.
+
+ The w\bwa\bai\bit\btp\bpi\bid\bd() call is identical to w\bwa\bai\bit\bt4\b4() with an _\br_\bu_\bs_\ba_\bg_\be value of zero.
+ The older w\bwa\bai\bit\bt3\b3() call is the same as w\bwa\bai\bit\bt4\b4() with a _\bw_\bp_\bi_\bd value of -1.
+
+ The following macros may be used to test the manner of exit of the
+ process. One of the first three macros will evaluate to a non-zero
+ (true) value:
+
+ W\bWI\bIF\bFC\bCO\bON\bNT\bTI\bIN\bNU\bUE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, and has continued after a
+ job control stop. This macro can be true only if the wait call
+ specified the WCONTINUED option.
+
+ W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated normally by a call to _exit(2) or
+ exit(3).
+
+ W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated due to receipt of a signal.
+
+ W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, but has stopped and can
+ be restarted. This macro can be true only if the wait call
+ specified the WUNTRACED option or if the child process is being
+ traced (see ptrace(2)).
+
+ Depending on the values of those macros, the following macros produce the
+ remaining status information about the child process:
+
+ W\bWE\bEX\bXI\bIT\bTS\bST\bTA\bAT\bTU\bUS\bS(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the low-order 8 bits
+ of the argument passed to _exit(2) or exit(3) by the child.
+
+ W\bWT\bTE\bER\bRM\bMS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the termination of the process.
+
+ W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates as true if the
+ termination of the process was accompanied by the creation of a
+ core file containing an image of the process when the signal was
+ received.
+
+ W\bWS\bST\bTO\bOP\bPS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the process to stop.
+
+N\bNO\bOT\bTE\bES\bS
+ See sigaction(2) for a list of termination signals. A status of 0
+ indicates normal termination.
+
+ If a parent process terminates without waiting for all of its child
+ processes to terminate, the remaining child processes are assigned the
+ parent process 1 ID (the init process ID).
+
+ If a signal is caught while any of the w\bwa\bai\bit\bt() calls is pending, the call
+ may be interrupted or restarted when the signal-catching routine returns,
+ depending on the options in effect for the signal; for further
+ information, see siginterrupt(3).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If w\bwa\bai\bit\bt() returns due to a stopped or terminated child process, the
+ process ID of the child is returned to the calling process. Otherwise, a
+ value of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+ If w\bwa\bai\bit\bt4\b4(), w\bwa\bai\bit\bt3\b3() or w\bwa\bai\bit\btp\bpi\bid\bd() returns due to a stopped or terminated
+ child process, the process ID of the child is returned to the calling
+ process. If there are no children not previously awaited, -1 is returned
+ with _\be_\br_\br_\bn_\bo set to [ECHILD]. Otherwise, if WNOHANG is specified and there
+ are no stopped or exited children, 0 is returned. If an error is
+ detected or a caught signal aborts the call, a value of -1 is returned
+ and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ w\bwa\bai\bit\bt() will fail and return immediately if:
+
+ [ECHILD] The calling process has no existing unwaited-for child
+ processes.
+
+ [EFAULT] The _\bs_\bt_\ba_\bt_\bu_\bs or _\br_\bu_\bs_\ba_\bg_\be arguments point to an illegal
+ address. (May not be detected before exit of a child
+ process.)
+
+ [EINTR] The call was interrupted by a caught signal, or the
+ signal did not have the SA_RESTART flag set.
+
+ [EINVAL] Invalid or undefined flags were passed in the _\bo_\bp_\bt_\bi_\bo_\bn_\bs
+ argument.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ _exit(2), sigaction(2), exit(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The w\bwa\bai\bit\bt() and w\bwa\bai\bit\btp\bpi\bid\bd() functions conform to IEEE Std 1003.1-2008
+ (``POSIX.1'').
+
+ w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\bt3\b3() are not specified by POSIX. The W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP() macro
+ and the ability to restart a pending w\bwa\bai\bit\bt() call are extensions to that
+ specification.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A w\bwa\bai\bit\bt() system call first appeared in Version 1 AT&T UNIX. The _\bs_\bt_\ba_\bt_\bu_\bs
+ argument is accepted since Version 2 AT&T UNIX. A w\bwa\bai\bit\bt3\b3() system call
+ first appeared in 4BSD, but the final calling convention was only
+ established in 4.2BSD. The w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\btp\bpi\bid\bd() function calls first
+ appeared in 4.3BSD-Reno.
+
+N\bNA\bAM\bME\bE
+ w\bwa\bai\bit\bt, w\bwa\bai\bit\btp\bpi\bid\bd, w\bwa\bai\bit\bt4\b4, w\bwa\bai\bit\bt3\b3 - wait for process termination
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\btp\bpi\bid\bd(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt3\b3(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt4\b4(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The w\bwa\bai\bit\bt() function suspends execution of its calling process until
+ _\bs_\bt_\ba_\bt_\bu_\bs information is available for a terminated child process, or a
+ signal is received. On return from a successful w\bwa\bai\bit\bt() call, the _\bs_\bt_\ba_\bt_\bu_\bs
+ area, if non-zero, is filled in with termination information about the
+ process that exited (see below).
+
+ The w\bwa\bai\bit\bt4\b4() call provides a more general interface for programs that need
+ to wait for certain child processes, that need resource utilization
+ statistics accumulated by child processes, or that require options. The
+ other wait functions are implemented using w\bwa\bai\bit\bt4\b4().
+
+ The _\bw_\bp_\bi_\bd parameter specifies the set of child processes for which to
+ wait. The following symbolic constants are currently defined in
+ <_\bs_\by_\bs_\b/_\bw_\ba_\bi_\bt_\b._\bh>:
+
+ #define WAIT_ANY (-1) /* any process */
+ #define WAIT_MYPGRP 0 /* any process in my process group */
+
+ If _\bw_\bp_\bi_\bd is set to WAIT_ANY, the call waits for any child process. If
+ _\bw_\bp_\bi_\bd is set to WAIT_MYPGRP, the call waits for any child process in the
+ process group of the caller. If _\bw_\bp_\bi_\bd is greater than zero, the call
+ waits for the process with process ID _\bw_\bp_\bi_\bd. If _\bw_\bp_\bi_\bd is less than -1, the
+ call waits for any process whose process group ID equals the absolute
+ value of _\bw_\bp_\bi_\bd.
+
+ The _\bs_\bt_\ba_\bt_\bu_\bs parameter is defined below. The _\bo_\bp_\bt_\bi_\bo_\bn_\bs argument is the
+ bitwise OR of zero or more of the following values:
+
+ WCONTINUED Causes status to be reported for stopped child processes that
+ have been continued by receipt of a SIGCONT signal.
+
+ WNOHANG Indicates that the call should not block if there are no
+ processes that wish to report status.
+
+ WUNTRACED If set, children of the current process that are stopped due
+ to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal also have
+ their status reported.
+
+ If _\br_\bu_\bs_\ba_\bg_\be is non-zero, a summary of the resources used by the terminated
+ process and all its children is returned (this information is currently
+ not available for stopped processes).
+
+ When the WNOHANG option is specified and no processes wish to report
+ status, w\bwa\bai\bit\bt4\b4() returns a process ID of 0.
+
+ The w\bwa\bai\bit\btp\bpi\bid\bd() call is identical to w\bwa\bai\bit\bt4\b4() with an _\br_\bu_\bs_\ba_\bg_\be value of zero.
+ The older w\bwa\bai\bit\bt3\b3() call is the same as w\bwa\bai\bit\bt4\b4() with a _\bw_\bp_\bi_\bd value of -1.
+
+ The following macros may be used to test the manner of exit of the
+ process. One of the first three macros will evaluate to a non-zero
+ (true) value:
+
+ W\bWI\bIF\bFC\bCO\bON\bNT\bTI\bIN\bNU\bUE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, and has continued after a
+ job control stop. This macro can be true only if the wait call
+ specified the WCONTINUED option.
+
+ W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated normally by a call to _exit(2) or
+ exit(3).
+
+ W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated due to receipt of a signal.
+
+ W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, but has stopped and can
+ be restarted. This macro can be true only if the wait call
+ specified the WUNTRACED option or if the child process is being
+ traced (see ptrace(2)).
+
+ Depending on the values of those macros, the following macros produce the
+ remaining status information about the child process:
+
+ W\bWE\bEX\bXI\bIT\bTS\bST\bTA\bAT\bTU\bUS\bS(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the low-order 8 bits
+ of the argument passed to _exit(2) or exit(3) by the child.
+
+ W\bWT\bTE\bER\bRM\bMS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the termination of the process.
+
+ W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates as true if the
+ termination of the process was accompanied by the creation of a
+ core file containing an image of the process when the signal was
+ received.
+
+ W\bWS\bST\bTO\bOP\bPS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the process to stop.
+
+N\bNO\bOT\bTE\bES\bS
+ See sigaction(2) for a list of termination signals. A status of 0
+ indicates normal termination.
+
+ If a parent process terminates without waiting for all of its child
+ processes to terminate, the remaining child processes are assigned the
+ parent process 1 ID (the init process ID).
+
+ If a signal is caught while any of the w\bwa\bai\bit\bt() calls is pending, the call
+ may be interrupted or restarted when the signal-catching routine returns,
+ depending on the options in effect for the signal; for further
+ information, see siginterrupt(3).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If w\bwa\bai\bit\bt() returns due to a stopped or terminated child process, the
+ process ID of the child is returned to the calling process. Otherwise, a
+ value of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+ If w\bwa\bai\bit\bt4\b4(), w\bwa\bai\bit\bt3\b3() or w\bwa\bai\bit\btp\bpi\bid\bd() returns due to a stopped or terminated
+ child process, the process ID of the child is returned to the calling
+ process. If there are no children not previously awaited, -1 is returned
+ with _\be_\br_\br_\bn_\bo set to [ECHILD]. Otherwise, if WNOHANG is specified and there
+ are no stopped or exited children, 0 is returned. If an error is
+ detected or a caught signal aborts the call, a value of -1 is returned
+ and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ w\bwa\bai\bit\bt() will fail and return immediately if:
+
+ [ECHILD] The calling process has no existing unwaited-for child
+ processes.
+
+ [EFAULT] The _\bs_\bt_\ba_\bt_\bu_\bs or _\br_\bu_\bs_\ba_\bg_\be arguments point to an illegal
+ address. (May not be detected before exit of a child
+ process.)
+
+ [EINTR] The call was interrupted by a caught signal, or the
+ signal did not have the SA_RESTART flag set.
+
+ [EINVAL] Invalid or undefined flags were passed in the _\bo_\bp_\bt_\bi_\bo_\bn_\bs
+ argument.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ _exit(2), sigaction(2), exit(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The w\bwa\bai\bit\bt() and w\bwa\bai\bit\btp\bpi\bid\bd() functions conform to IEEE Std 1003.1-2008
+ (``POSIX.1'').
+
+ w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\bt3\b3() are not specified by POSIX. The W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP() macro
+ and the ability to restart a pending w\bwa\bai\bit\bt() call are extensions to that
+ specification.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A w\bwa\bai\bit\bt() system call first appeared in Version 1 AT&T UNIX. The _\bs_\bt_\ba_\bt_\bu_\bs
+ argument is accepted since Version 2 AT&T UNIX. A w\bwa\bai\bit\bt3\b3() system call
+ first appeared in 4BSD, but the final calling convention was only
+ established in 4.2BSD. The w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\btp\bpi\bid\bd() function calls first
+ appeared in 4.3BSD-Reno.
+
+N\bNA\bAM\bME\bE
+ w\bwa\bai\bit\bt, w\bwa\bai\bit\btp\bpi\bid\bd, w\bwa\bai\bit\bt4\b4, w\bwa\bai\bit\bt3\b3 - wait for process termination
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\btp\bpi\bid\bd(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt3\b3(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt4\b4(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The w\bwa\bai\bit\bt() function suspends execution of its calling process until
+ _\bs_\bt_\ba_\bt_\bu_\bs information is available for a terminated child process, or a
+ signal is received. On return from a successful w\bwa\bai\bit\bt() call, the _\bs_\bt_\ba_\bt_\bu_\bs
+ area, if non-zero, is filled in with termination information about the
+ process that exited (see below).
+
+ The w\bwa\bai\bit\bt4\b4() call provides a more general interface for programs that need
+ to wait for certain child processes, that need resource utilization
+ statistics accumulated by child processes, or that require options. The
+ other wait functions are implemented using w\bwa\bai\bit\bt4\b4().
+
+ The _\bw_\bp_\bi_\bd parameter specifies the set of child processes for which to
+ wait. The following symbolic constants are currently defined in
+ <_\bs_\by_\bs_\b/_\bw_\ba_\bi_\bt_\b._\bh>:
+
+ #define WAIT_ANY (-1) /* any process */
+ #define WAIT_MYPGRP 0 /* any process in my process group */
+
+ If _\bw_\bp_\bi_\bd is set to WAIT_ANY, the call waits for any child process. If
+ _\bw_\bp_\bi_\bd is set to WAIT_MYPGRP, the call waits for any child process in the
+ process group of the caller. If _\bw_\bp_\bi_\bd is greater than zero, the call
+ waits for the process with process ID _\bw_\bp_\bi_\bd. If _\bw_\bp_\bi_\bd is less than -1, the
+ call waits for any process whose process group ID equals the absolute
+ value of _\bw_\bp_\bi_\bd.
+
+ The _\bs_\bt_\ba_\bt_\bu_\bs parameter is defined below. The _\bo_\bp_\bt_\bi_\bo_\bn_\bs argument is the
+ bitwise OR of zero or more of the following values:
+
+ WCONTINUED Causes status to be reported for stopped child processes that
+ have been continued by receipt of a SIGCONT signal.
+
+ WNOHANG Indicates that the call should not block if there are no
+ processes that wish to report status.
+
+ WUNTRACED If set, children of the current process that are stopped due
+ to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal also have
+ their status reported.
+
+ If _\br_\bu_\bs_\ba_\bg_\be is non-zero, a summary of the resources used by the terminated
+ process and all its children is returned (this information is currently
+ not available for stopped processes).
+
+ When the WNOHANG option is specified and no processes wish to report
+ status, w\bwa\bai\bit\bt4\b4() returns a process ID of 0.
+
+ The w\bwa\bai\bit\btp\bpi\bid\bd() call is identical to w\bwa\bai\bit\bt4\b4() with an _\br_\bu_\bs_\ba_\bg_\be value of zero.
+ The older w\bwa\bai\bit\bt3\b3() call is the same as w\bwa\bai\bit\bt4\b4() with a _\bw_\bp_\bi_\bd value of -1.
+
+ The following macros may be used to test the manner of exit of the
+ process. One of the first three macros will evaluate to a non-zero
+ (true) value:
+
+ W\bWI\bIF\bFC\bCO\bON\bNT\bTI\bIN\bNU\bUE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, and has continued after a
+ job control stop. This macro can be true only if the wait call
+ specified the WCONTINUED option.
+
+ W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated normally by a call to _exit(2) or
+ exit(3).
+
+ W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated due to receipt of a signal.
+
+ W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, but has stopped and can
+ be restarted. This macro can be true only if the wait call
+ specified the WUNTRACED option or if the child process is being
+ traced (see ptrace(2)).
+
+ Depending on the values of those macros, the following macros produce the
+ remaining status information about the child process:
+
+ W\bWE\bEX\bXI\bIT\bTS\bST\bTA\bAT\bTU\bUS\bS(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the low-order 8 bits
+ of the argument passed to _exit(2) or exit(3) by the child.
+
+ W\bWT\bTE\bER\bRM\bMS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the termination of the process.
+
+ W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates as true if the
+ termination of the process was accompanied by the creation of a
+ core file containing an image of the process when the signal was
+ received.
+
+ W\bWS\bST\bTO\bOP\bPS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the process to stop.
+
+N\bNO\bOT\bTE\bES\bS
+ See sigaction(2) for a list of termination signals. A status of 0
+ indicates normal termination.
+
+ If a parent process terminates without waiting for all of its child
+ processes to terminate, the remaining child processes are assigned the
+ parent process 1 ID (the init process ID).
+
+ If a signal is caught while any of the w\bwa\bai\bit\bt() calls is pending, the call
+ may be interrupted or restarted when the signal-catching routine returns,
+ depending on the options in effect for the signal; for further
+ information, see siginterrupt(3).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If w\bwa\bai\bit\bt() returns due to a stopped or terminated child process, the
+ process ID of the child is returned to the calling process. Otherwise, a
+ value of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+ If w\bwa\bai\bit\bt4\b4(), w\bwa\bai\bit\bt3\b3() or w\bwa\bai\bit\btp\bpi\bid\bd() returns due to a stopped or terminated
+ child process, the process ID of the child is returned to the calling
+ process. If there are no children not previously awaited, -1 is returned
+ with _\be_\br_\br_\bn_\bo set to [ECHILD]. Otherwise, if WNOHANG is specified and there
+ are no stopped or exited children, 0 is returned. If an error is
+ detected or a caught signal aborts the call, a value of -1 is returned
+ and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ w\bwa\bai\bit\bt() will fail and return immediately if:
+
+ [ECHILD] The calling process has no existing unwaited-for child
+ processes.
+
+ [EFAULT] The _\bs_\bt_\ba_\bt_\bu_\bs or _\br_\bu_\bs_\ba_\bg_\be arguments point to an illegal
+ address. (May not be detected before exit of a child
+ process.)
+
+ [EINTR] The call was interrupted by a caught signal, or the
+ signal did not have the SA_RESTART flag set.
+
+ [EINVAL] Invalid or undefined flags were passed in the _\bo_\bp_\bt_\bi_\bo_\bn_\bs
+ argument.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ _exit(2), sigaction(2), exit(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The w\bwa\bai\bit\bt() and w\bwa\bai\bit\btp\bpi\bid\bd() functions conform to IEEE Std 1003.1-2008
+ (``POSIX.1'').
+
+ w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\bt3\b3() are not specified by POSIX. The W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP() macro
+ and the ability to restart a pending w\bwa\bai\bit\bt() call are extensions to that
+ specification.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A w\bwa\bai\bit\bt() system call first appeared in Version 1 AT&T UNIX. The _\bs_\bt_\ba_\bt_\bu_\bs
+ argument is accepted since Version 2 AT&T UNIX. A w\bwa\bai\bit\bt3\b3() system call
+ first appeared in 4BSD, but the final calling convention was only
+ established in 4.2BSD. The w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\btp\bpi\bid\bd() function calls first
+ appeared in 4.3BSD-Reno.
+
+N\bNA\bAM\bME\bE
+ w\bwa\bai\bit\bt, w\bwa\bai\bit\btp\bpi\bid\bd, w\bwa\bai\bit\bt4\b4, w\bwa\bai\bit\bt3\b3 - wait for process termination
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\btp\bpi\bid\bd(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt3\b3(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt4\b4(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The w\bwa\bai\bit\bt() function suspends execution of its calling process until
+ _\bs_\bt_\ba_\bt_\bu_\bs information is available for a terminated child process, or a
+ signal is received. On return from a successful w\bwa\bai\bit\bt() call, the _\bs_\bt_\ba_\bt_\bu_\bs
+ area, if non-zero, is filled in with termination information about the
+ process that exited (see below).
+
+ The w\bwa\bai\bit\bt4\b4() call provides a more general interface for programs that need
+ to wait for certain child processes, that need resource utilization
+ statistics accumulated by child processes, or that require options. The
+ other wait functions are implemented using w\bwa\bai\bit\bt4\b4().
+
+ The _\bw_\bp_\bi_\bd parameter specifies the set of child processes for which to
+ wait. The following symbolic constants are currently defined in
+ <_\bs_\by_\bs_\b/_\bw_\ba_\bi_\bt_\b._\bh>:
+
+ #define WAIT_ANY (-1) /* any process */
+ #define WAIT_MYPGRP 0 /* any process in my process group */
+
+ If _\bw_\bp_\bi_\bd is set to WAIT_ANY, the call waits for any child process. If
+ _\bw_\bp_\bi_\bd is set to WAIT_MYPGRP, the call waits for any child process in the
+ process group of the caller. If _\bw_\bp_\bi_\bd is greater than zero, the call
+ waits for the process with process ID _\bw_\bp_\bi_\bd. If _\bw_\bp_\bi_\bd is less than -1, the
+ call waits for any process whose process group ID equals the absolute
+ value of _\bw_\bp_\bi_\bd.
+
+ The _\bs_\bt_\ba_\bt_\bu_\bs parameter is defined below. The _\bo_\bp_\bt_\bi_\bo_\bn_\bs argument is the
+ bitwise OR of zero or more of the following values:
+
+ WCONTINUED Causes status to be reported for stopped child processes that
+ have been continued by receipt of a SIGCONT signal.
+
+ WNOHANG Indicates that the call should not block if there are no
+ processes that wish to report status.
+
+ WUNTRACED If set, children of the current process that are stopped due
+ to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal also have
+ their status reported.
+
+ If _\br_\bu_\bs_\ba_\bg_\be is non-zero, a summary of the resources used by the terminated
+ process and all its children is returned (this information is currently
+ not available for stopped processes).
+
+ When the WNOHANG option is specified and no processes wish to report
+ status, w\bwa\bai\bit\bt4\b4() returns a process ID of 0.
+
+ The w\bwa\bai\bit\btp\bpi\bid\bd() call is identical to w\bwa\bai\bit\bt4\b4() with an _\br_\bu_\bs_\ba_\bg_\be value of zero.
+ The older w\bwa\bai\bit\bt3\b3() call is the same as w\bwa\bai\bit\bt4\b4() with a _\bw_\bp_\bi_\bd value of -1.
+
+ The following macros may be used to test the manner of exit of the
+ process. One of the first three macros will evaluate to a non-zero
+ (true) value:
+
+ W\bWI\bIF\bFC\bCO\bON\bNT\bTI\bIN\bNU\bUE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, and has continued after a
+ job control stop. This macro can be true only if the wait call
+ specified the WCONTINUED option.
+
+ W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated normally by a call to _exit(2) or
+ exit(3).
+
+ W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated due to receipt of a signal.
+
+ W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, but has stopped and can
+ be restarted. This macro can be true only if the wait call
+ specified the WUNTRACED option or if the child process is being
+ traced (see ptrace(2)).
+
+ Depending on the values of those macros, the following macros produce the
+ remaining status information about the child process:
+
+ W\bWE\bEX\bXI\bIT\bTS\bST\bTA\bAT\bTU\bUS\bS(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the low-order 8 bits
+ of the argument passed to _exit(2) or exit(3) by the child.
+
+ W\bWT\bTE\bER\bRM\bMS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the termination of the process.
+
+ W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates as true if the
+ termination of the process was accompanied by the creation of a
+ core file containing an image of the process when the signal was
+ received.
+
+ W\bWS\bST\bTO\bOP\bPS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the process to stop.
+
+N\bNO\bOT\bTE\bES\bS
+ See sigaction(2) for a list of termination signals. A status of 0
+ indicates normal termination.
+
+ If a parent process terminates without waiting for all of its child
+ processes to terminate, the remaining child processes are assigned the
+ parent process 1 ID (the init process ID).
+
+ If a signal is caught while any of the w\bwa\bai\bit\bt() calls is pending, the call
+ may be interrupted or restarted when the signal-catching routine returns,
+ depending on the options in effect for the signal; for further
+ information, see siginterrupt(3).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If w\bwa\bai\bit\bt() returns due to a stopped or terminated child process, the
+ process ID of the child is returned to the calling process. Otherwise, a
+ value of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+ If w\bwa\bai\bit\bt4\b4(), w\bwa\bai\bit\bt3\b3() or w\bwa\bai\bit\btp\bpi\bid\bd() returns due to a stopped or terminated
+ child process, the process ID of the child is returned to the calling
+ process. If there are no children not previously awaited, -1 is returned
+ with _\be_\br_\br_\bn_\bo set to [ECHILD]. Otherwise, if WNOHANG is specified and there
+ are no stopped or exited children, 0 is returned. If an error is
+ detected or a caught signal aborts the call, a value of -1 is returned
+ and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ w\bwa\bai\bit\bt() will fail and return immediately if:
+
+ [ECHILD] The calling process has no existing unwaited-for child
+ processes.
+
+ [EFAULT] The _\bs_\bt_\ba_\bt_\bu_\bs or _\br_\bu_\bs_\ba_\bg_\be arguments point to an illegal
+ address. (May not be detected before exit of a child
+ process.)
+
+ [EINTR] The call was interrupted by a caught signal, or the
+ signal did not have the SA_RESTART flag set.
+
+ [EINVAL] Invalid or undefined flags were passed in the _\bo_\bp_\bt_\bi_\bo_\bn_\bs
+ argument.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ _exit(2), sigaction(2), exit(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The w\bwa\bai\bit\bt() and w\bwa\bai\bit\btp\bpi\bid\bd() functions conform to IEEE Std 1003.1-2008
+ (``POSIX.1'').
+
+ w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\bt3\b3() are not specified by POSIX. The W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP() macro
+ and the ability to restart a pending w\bwa\bai\bit\bt() call are extensions to that
+ specification.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A w\bwa\bai\bit\bt() system call first appeared in Version 1 AT&T UNIX. The _\bs_\bt_\ba_\bt_\bu_\bs
+ argument is accepted since Version 2 AT&T UNIX. A w\bwa\bai\bit\bt3\b3() system call
+ first appeared in 4BSD, but the final calling convention was only
+ established in 4.2BSD. The w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\btp\bpi\bid\bd() function calls first
+ appeared in 4.3BSD-Reno.
+
+N\bNA\bAM\bME\bE
+ w\bwa\bai\bit\bt, w\bwa\bai\bit\btp\bpi\bid\bd, w\bwa\bai\bit\bt4\b4, w\bwa\bai\bit\bt3\b3 - wait for process termination
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\btp\bpi\bid\bd(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt3\b3(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt4\b4(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The w\bwa\bai\bit\bt() function suspends execution of its calling process until
+ _\bs_\bt_\ba_\bt_\bu_\bs information is available for a terminated child process, or a
+ signal is received. On return from a successful w\bwa\bai\bit\bt() call, the _\bs_\bt_\ba_\bt_\bu_\bs
+ area, if non-zero, is filled in with termination information about the
+ process that exited (see below).
+
+ The w\bwa\bai\bit\bt4\b4() call provides a more general interface for programs that need
+ to wait for certain child processes, that need resource utilization
+ statistics accumulated by child processes, or that require options. The
+ other wait functions are implemented using w\bwa\bai\bit\bt4\b4().
+
+ The _\bw_\bp_\bi_\bd parameter specifies the set of child processes for which to
+ wait. The following symbolic constants are currently defined in
+ <_\bs_\by_\bs_\b/_\bw_\ba_\bi_\bt_\b._\bh>:
+
+ #define WAIT_ANY (-1) /* any process */
+ #define WAIT_MYPGRP 0 /* any process in my process group */
+
+ If _\bw_\bp_\bi_\bd is set to WAIT_ANY, the call waits for any child process. If
+ _\bw_\bp_\bi_\bd is set to WAIT_MYPGRP, the call waits for any child process in the
+ process group of the caller. If _\bw_\bp_\bi_\bd is greater than zero, the call
+ waits for the process with process ID _\bw_\bp_\bi_\bd. If _\bw_\bp_\bi_\bd is less than -1, the
+ call waits for any process whose process group ID equals the absolute
+ value of _\bw_\bp_\bi_\bd.
+
+ The _\bs_\bt_\ba_\bt_\bu_\bs parameter is defined below. The _\bo_\bp_\bt_\bi_\bo_\bn_\bs argument is the
+ bitwise OR of zero or more of the following values:
+
+ WCONTINUED Causes status to be reported for stopped child processes that
+ have been continued by receipt of a SIGCONT signal.
+
+ WNOHANG Indicates that the call should not block if there are no
+ processes that wish to report status.
+
+ WUNTRACED If set, children of the current process that are stopped due
+ to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal also have
+ their status reported.
+
+ If _\br_\bu_\bs_\ba_\bg_\be is non-zero, a summary of the resources used by the terminated
+ process and all its children is returned (this information is currently
+ not available for stopped processes).
+
+ When the WNOHANG option is specified and no processes wish to report
+ status, w\bwa\bai\bit\bt4\b4() returns a process ID of 0.
+
+ The w\bwa\bai\bit\btp\bpi\bid\bd() call is identical to w\bwa\bai\bit\bt4\b4() with an _\br_\bu_\bs_\ba_\bg_\be value of zero.
+ The older w\bwa\bai\bit\bt3\b3() call is the same as w\bwa\bai\bit\bt4\b4() with a _\bw_\bp_\bi_\bd value of -1.
+
+ The following macros may be used to test the manner of exit of the
+ process. One of the first three macros will evaluate to a non-zero
+ (true) value:
+
+ W\bWI\bIF\bFC\bCO\bON\bNT\bTI\bIN\bNU\bUE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, and has continued after a
+ job control stop. This macro can be true only if the wait call
+ specified the WCONTINUED option.
+
+ W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated normally by a call to _exit(2) or
+ exit(3).
+
+ W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated due to receipt of a signal.
+
+ W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, but has stopped and can
+ be restarted. This macro can be true only if the wait call
+ specified the WUNTRACED option or if the child process is being
+ traced (see ptrace(2)).
+
+ Depending on the values of those macros, the following macros produce the
+ remaining status information about the child process:
+
+ W\bWE\bEX\bXI\bIT\bTS\bST\bTA\bAT\bTU\bUS\bS(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the low-order 8 bits
+ of the argument passed to _exit(2) or exit(3) by the child.
+
+ W\bWT\bTE\bER\bRM\bMS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the termination of the process.
+
+ W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates as true if the
+ termination of the process was accompanied by the creation of a
+ core file containing an image of the process when the signal was
+ received.
+
+ W\bWS\bST\bTO\bOP\bPS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the process to stop.
+
+N\bNO\bOT\bTE\bES\bS
+ See sigaction(2) for a list of termination signals. A status of 0
+ indicates normal termination.
+
+ If a parent process terminates without waiting for all of its child
+ processes to terminate, the remaining child processes are assigned the
+ parent process 1 ID (the init process ID).
+
+ If a signal is caught while any of the w\bwa\bai\bit\bt() calls is pending, the call
+ may be interrupted or restarted when the signal-catching routine returns,
+ depending on the options in effect for the signal; for further
+ information, see siginterrupt(3).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If w\bwa\bai\bit\bt() returns due to a stopped or terminated child process, the
+ process ID of the child is returned to the calling process. Otherwise, a
+ value of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+ If w\bwa\bai\bit\bt4\b4(), w\bwa\bai\bit\bt3\b3() or w\bwa\bai\bit\btp\bpi\bid\bd() returns due to a stopped or terminated
+ child process, the process ID of the child is returned to the calling
+ process. If there are no children not previously awaited, -1 is returned
+ with _\be_\br_\br_\bn_\bo set to [ECHILD]. Otherwise, if WNOHANG is specified and there
+ are no stopped or exited children, 0 is returned. If an error is
+ detected or a caught signal aborts the call, a value of -1 is returned
+ and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ w\bwa\bai\bit\bt() will fail and return immediately if:
+
+ [ECHILD] The calling process has no existing unwaited-for child
+ processes.
+
+ [EFAULT] The _\bs_\bt_\ba_\bt_\bu_\bs or _\br_\bu_\bs_\ba_\bg_\be arguments point to an illegal
+ address. (May not be detected before exit of a child
+ process.)
+
+ [EINTR] The call was interrupted by a caught signal, or the
+ signal did not have the SA_RESTART flag set.
+
+ [EINVAL] Invalid or undefined flags were passed in the _\bo_\bp_\bt_\bi_\bo_\bn_\bs
+ argument.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ _exit(2), sigaction(2), exit(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The w\bwa\bai\bit\bt() and w\bwa\bai\bit\btp\bpi\bid\bd() functions conform to IEEE Std 1003.1-2008
+ (``POSIX.1'').
+
+ w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\bt3\b3() are not specified by POSIX. The W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP() macro
+ and the ability to restart a pending w\bwa\bai\bit\bt() call are extensions to that
+ specification.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A w\bwa\bai\bit\bt() system call first appeared in Version 1 AT&T UNIX. The _\bs_\bt_\ba_\bt_\bu_\bs
+ argument is accepted since Version 2 AT&T UNIX. A w\bwa\bai\bit\bt3\b3() system call
+ first appeared in 4BSD, but the final calling convention was only
+ established in 4.2BSD. The w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\btp\bpi\bid\bd() function calls first
+ appeared in 4.3BSD-Reno.
+
+N\bNA\bAM\bME\bE
+ w\bwa\bai\bit\bt, w\bwa\bai\bit\btp\bpi\bid\bd, w\bwa\bai\bit\bt4\b4, w\bwa\bai\bit\bt3\b3 - wait for process termination
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\btp\bpi\bid\bd(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/w\bwa\bai\bit\bt.\b.h\bh>\b>
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt3\b3(_\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+ _\bp_\bi_\bd_\b__\bt
+ w\bwa\bai\bit\bt4\b4(_\bp_\bi_\bd_\b__\bt _\bw_\bp_\bi_\bd, _\bi_\bn_\bt _\b*_\bs_\bt_\ba_\bt_\bu_\bs, _\bi_\bn_\bt _\bo_\bp_\bt_\bi_\bo_\bn_\bs, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The w\bwa\bai\bit\bt() function suspends execution of its calling process until
+ _\bs_\bt_\ba_\bt_\bu_\bs information is available for a terminated child process, or a
+ signal is received. On return from a successful w\bwa\bai\bit\bt() call, the _\bs_\bt_\ba_\bt_\bu_\bs
+ area, if non-zero, is filled in with termination information about the
+ process that exited (see below).
+
+ The w\bwa\bai\bit\bt4\b4() call provides a more general interface for programs that need
+ to wait for certain child processes, that need resource utilization
+ statistics accumulated by child processes, or that require options. The
+ other wait functions are implemented using w\bwa\bai\bit\bt4\b4().
+
+ The _\bw_\bp_\bi_\bd parameter specifies the set of child processes for which to
+ wait. The following symbolic constants are currently defined in
+ <_\bs_\by_\bs_\b/_\bw_\ba_\bi_\bt_\b._\bh>:
+
+ #define WAIT_ANY (-1) /* any process */
+ #define WAIT_MYPGRP 0 /* any process in my process group */
+
+ If _\bw_\bp_\bi_\bd is set to WAIT_ANY, the call waits for any child process. If
+ _\bw_\bp_\bi_\bd is set to WAIT_MYPGRP, the call waits for any child process in the
+ process group of the caller. If _\bw_\bp_\bi_\bd is greater than zero, the call
+ waits for the process with process ID _\bw_\bp_\bi_\bd. If _\bw_\bp_\bi_\bd is less than -1, the
+ call waits for any process whose process group ID equals the absolute
+ value of _\bw_\bp_\bi_\bd.
+
+ The _\bs_\bt_\ba_\bt_\bu_\bs parameter is defined below. The _\bo_\bp_\bt_\bi_\bo_\bn_\bs argument is the
+ bitwise OR of zero or more of the following values:
+
+ WCONTINUED Causes status to be reported for stopped child processes that
+ have been continued by receipt of a SIGCONT signal.
+
+ WNOHANG Indicates that the call should not block if there are no
+ processes that wish to report status.
+
+ WUNTRACED If set, children of the current process that are stopped due
+ to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal also have
+ their status reported.
+
+ If _\br_\bu_\bs_\ba_\bg_\be is non-zero, a summary of the resources used by the terminated
+ process and all its children is returned (this information is currently
+ not available for stopped processes).
+
+ When the WNOHANG option is specified and no processes wish to report
+ status, w\bwa\bai\bit\bt4\b4() returns a process ID of 0.
+
+ The w\bwa\bai\bit\btp\bpi\bid\bd() call is identical to w\bwa\bai\bit\bt4\b4() with an _\br_\bu_\bs_\ba_\bg_\be value of zero.
+ The older w\bwa\bai\bit\bt3\b3() call is the same as w\bwa\bai\bit\bt4\b4() with a _\bw_\bp_\bi_\bd value of -1.
+
+ The following macros may be used to test the manner of exit of the
+ process. One of the first three macros will evaluate to a non-zero
+ (true) value:
+
+ W\bWI\bIF\bFC\bCO\bON\bNT\bTI\bIN\bNU\bUE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, and has continued after a
+ job control stop. This macro can be true only if the wait call
+ specified the WCONTINUED option.
+
+ W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated normally by a call to _exit(2) or
+ exit(3).
+
+ W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process terminated due to receipt of a signal.
+
+ W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs)
+ True if the process has not terminated, but has stopped and can
+ be restarted. This macro can be true only if the wait call
+ specified the WUNTRACED option or if the child process is being
+ traced (see ptrace(2)).
+
+ Depending on the values of those macros, the following macros produce the
+ remaining status information about the child process:
+
+ W\bWE\bEX\bXI\bIT\bTS\bST\bTA\bAT\bTU\bUS\bS(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFE\bEX\bXI\bIT\bTE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the low-order 8 bits
+ of the argument passed to _exit(2) or exit(3) by the child.
+
+ W\bWT\bTE\bER\bRM\bMS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the termination of the process.
+
+ W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bSI\bIG\bGN\bNA\bAL\bLE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates as true if the
+ termination of the process was accompanied by the creation of a
+ core file containing an image of the process when the signal was
+ received.
+
+ W\bWS\bST\bTO\bOP\bPS\bSI\bIG\bG(_\bs_\bt_\ba_\bt_\bu_\bs)
+ If W\bWI\bIF\bFS\bST\bTO\bOP\bPP\bPE\bED\bD(_\bs_\bt_\ba_\bt_\bu_\bs) is true, evaluates to the number of the
+ signal that caused the process to stop.
+
+N\bNO\bOT\bTE\bES\bS
+ See sigaction(2) for a list of termination signals. A status of 0
+ indicates normal termination.
+
+ If a parent process terminates without waiting for all of its child
+ processes to terminate, the remaining child processes are assigned the
+ parent process 1 ID (the init process ID).
+
+ If a signal is caught while any of the w\bwa\bai\bit\bt() calls is pending, the call
+ may be interrupted or restarted when the signal-catching routine returns,
+ depending on the options in effect for the signal; for further
+ information, see siginterrupt(3).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If w\bwa\bai\bit\bt() returns due to a stopped or terminated child process, the
+ process ID of the child is returned to the calling process. Otherwise, a
+ value of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+ If w\bwa\bai\bit\bt4\b4(), w\bwa\bai\bit\bt3\b3() or w\bwa\bai\bit\btp\bpi\bid\bd() returns due to a stopped or terminated
+ child process, the process ID of the child is returned to the calling
+ process. If there are no children not previously awaited, -1 is returned
+ with _\be_\br_\br_\bn_\bo set to [ECHILD]. Otherwise, if WNOHANG is specified and there
+ are no stopped or exited children, 0 is returned. If an error is
+ detected or a caught signal aborts the call, a value of -1 is returned
+ and _\be_\br_\br_\bn_\bo is set to indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ w\bwa\bai\bit\bt() will fail and return immediately if:
+
+ [ECHILD] The calling process has no existing unwaited-for child
+ processes.
+
+ [EFAULT] The _\bs_\bt_\ba_\bt_\bu_\bs or _\br_\bu_\bs_\ba_\bg_\be arguments point to an illegal
+ address. (May not be detected before exit of a child
+ process.)
+
+ [EINTR] The call was interrupted by a caught signal, or the
+ signal did not have the SA_RESTART flag set.
+
+ [EINVAL] Invalid or undefined flags were passed in the _\bo_\bp_\bt_\bi_\bo_\bn_\bs
+ argument.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ _exit(2), sigaction(2), exit(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The w\bwa\bai\bit\bt() and w\bwa\bai\bit\btp\bpi\bid\bd() functions conform to IEEE Std 1003.1-2008
+ (``POSIX.1'').
+
+ w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\bt3\b3() are not specified by POSIX. The W\bWC\bCO\bOR\bRE\bED\bDU\bUM\bMP\bP() macro
+ and the ability to restart a pending w\bwa\bai\bit\bt() call are extensions to that
+ specification.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A w\bwa\bai\bit\bt() system call first appeared in Version 1 AT&T UNIX. The _\bs_\bt_\ba_\bt_\bu_\bs
+ argument is accepted since Version 2 AT&T UNIX. A w\bwa\bai\bit\bt3\b3() system call
+ first appeared in 4BSD, but the final calling convention was only
+ established in 4.2BSD. The w\bwa\bai\bit\bt4\b4() and w\bwa\bai\bit\btp\bpi\bid\bd() function calls first
+ appeared in 4.3BSD-Reno.
+
+N\bNA\bAM\bME\bE
+ _\b_e\bex\bxi\bit\bt, _\b_E\bEx\bxi\bit\bt - terminate the calling process
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\bun\bni\bis\bst\btd\bd.\b.h\bh>\b>
+
+ _\bv_\bo_\bi_\bd
+ _\b_e\bex\bxi\bit\bt(_\bi_\bn_\bt _\bs_\bt_\ba_\bt_\bu_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bst\btd\bdl\bli\bib\bb.\b.h\bh>\b>
+
+ _\bv_\bo_\bi_\bd
+ _\b_E\bEx\bxi\bit\bt(_\bi_\bn_\bt _\bs_\bt_\ba_\bt_\bu_\bs);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The _\b_e\bex\bxi\bit\bt() and _\b_E\bEx\bxi\bit\bt() functions terminate a process with the following
+ consequences:
+
+ +\b+\bo\bo All threads in the process are terminated.
+
+ +\b+\bo\bo All open file descriptors in the calling process are closed. This
+ may entail delays; for example, waiting for output to drain. A
+ process in this state may not be killed, as it is already dying.
+
+ +\b+\bo\bo If the parent process of the calling process has an outstanding
+ wait(2) call or catches the SIGCHLD signal, it is notified of the
+ calling process's termination and _\bs_\bt_\ba_\bt_\bu_\bs is set as defined by
+ wait(2). (Note that typically only the lower 8 bits of _\bs_\bt_\ba_\bt_\bu_\bs are
+ passed on to the parent, thus negative values have less meaning.)
+
+ +\b+\bo\bo The parent process ID of all of the calling process's existing child
+ processes are set to 1; the initialization process (see the
+ DEFINITIONS section of intro(2)) inherits each of these processes.
+
+ +\b+\bo\bo If the termination of the process causes any process group to become
+ orphaned (usually because the parents of all members of the group
+ have now exited; see Orphaned Process Group in intro(2)), and if any
+ member of the orphaned group is stopped, the SIGHUP and SIGCONT
+ signals are sent to all members of the newly orphaned process group.
+
+ +\b+\bo\bo If the process is a controlling process (see intro(2)), the SIGHUP
+ signal is sent to the foreground process group of the controlling
+ terminal, and all current access to the controlling terminal is
+ revoked.
+
+ Most C programs call the library routine exit(3), which flushes buffers,
+ closes streams, unlinks temporary files, etc., and then calls _\b_e\bex\bxi\bit\bt().
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ _\b_e\bex\bxi\bit\bt() and _\b_E\bEx\bxi\bit\bt() can never return.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ fork(2), intro(2), sigaction(2), wait(2), exit(3), sysexits(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The _\b_e\bex\bxi\bit\bt() function conform to IEEE Std 1003.1-2008 (``POSIX.1''). The
+ _\b_E\bEx\bxi\bit\bt() function conforms to ISO/IEC 9899:1999 (``ISO C99'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ An e\bex\bxi\bit\bt() system call first appeared in Version 1 AT&T UNIX. It accepts
+ the _\bs_\bt_\ba_\bt_\bu_\bs argument since Version 2 AT&T UNIX. An _\b_e\bex\bxi\bit\bt() variant first
+ appeared in Version 7 AT&T UNIX. The _\b_E\bEx\bxi\bit\bt() function appeared in
+ OpenBSD 3.6.
+
+N\bNA\bAM\bME\bE
+ _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb, _\b__\b_s\bse\bet\bt_\b_t\btc\bcb\bb - get and set the address of the thread control
+ block of the current thread
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ _\bv_\bo_\bi_\bd _\b*
+ _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb(_\bv_\bo_\bi_\bd);
+
+ _\bv_\bo_\bi_\bd
+ _\b__\b_s\bse\bet\bt_\b_t\btc\bcb\bb(_\bv_\bo_\bi_\bd _\b*);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb() and _\b__\b_s\bse\bet\bt_\b_t\btc\bcb\bb() functions are for use by librthread and
+ other parts of the system runtime to retrieve and set the address of the
+ current thread's thread control block (TCB). This is used to locate per-
+ thread data such as _\be_\br_\br_\bn_\bo. Each kernel-level thread in a process has a
+ separate value for this address, which can be obtained and changed via
+ these system calls. New threads (including the first thread of a new
+ process) created using fork(2), vfork(2), or __tfork(2), inherit the TCB
+ address of the thread that created them. execve(2) resets it to zero.
+
+ On some platforms, this address is also directly mapped to a CPU register
+ which can be accessed from userspace.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb() returns the address of the thread control block of the
+ current thread.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ __tfork(2)
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb() and _\b__\b_s\bse\bet\bt_\b_t\btc\bcb\bb() system calls appeared in OpenBSD 5.1.
+
+N\bNA\bAM\bME\bE
+ _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb, _\b__\b_s\bse\bet\bt_\b_t\btc\bcb\bb - get and set the address of the thread control
+ block of the current thread
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ _\bv_\bo_\bi_\bd _\b*
+ _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb(_\bv_\bo_\bi_\bd);
+
+ _\bv_\bo_\bi_\bd
+ _\b__\b_s\bse\bet\bt_\b_t\btc\bcb\bb(_\bv_\bo_\bi_\bd _\b*);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb() and _\b__\b_s\bse\bet\bt_\b_t\btc\bcb\bb() functions are for use by librthread and
+ other parts of the system runtime to retrieve and set the address of the
+ current thread's thread control block (TCB). This is used to locate per-
+ thread data such as _\be_\br_\br_\bn_\bo. Each kernel-level thread in a process has a
+ separate value for this address, which can be obtained and changed via
+ these system calls. New threads (including the first thread of a new
+ process) created using fork(2), vfork(2), or __tfork(2), inherit the TCB
+ address of the thread that created them. execve(2) resets it to zero.
+
+ On some platforms, this address is also directly mapped to a CPU register
+ which can be accessed from userspace.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb() returns the address of the thread control block of the
+ current thread.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ __tfork(2)
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The _\b__\b_g\bge\bet\bt_\b_t\btc\bcb\bb() and _\b__\b_s\bse\bet\bt_\b_t\btc\bcb\bb() system calls appeared in OpenBSD 5.1.
+
+N\bNA\bAM\bME\bE
+ s\bsy\bys\bsc\bca\bal\bll\bl, _\b__\b_s\bsy\bys\bsc\bca\bal\bll\bl - indirect system call
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bsy\bys\bsc\bca\bal\bll\bl.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\bun\bni\bis\bst\btd\bd.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ s\bsy\bys\bsc\bca\bal\bll\bl(_\bi_\bn_\bt _\bn_\bu_\bm_\bb_\be_\br, _\b._\b._\b.);
+
+ _\b__\b_s\bsy\bys\bsc\bca\bal\bll\bl(_\bq_\bu_\ba_\bd_\b__\bt _\bn_\bu_\bm_\bb_\be_\br, _\b._\b._\b.);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ s\bsy\bys\bsc\bca\bal\bll\bl() performs the system call whose assembly language interface has
+ the specified _\bn_\bu_\bm_\bb_\be_\br with the specified arguments. Symbolic constants
+ for system calls can be found in the header file <_\bs_\by_\bs_\b/_\bs_\by_\bs_\bc_\ba_\bl_\bl_\b._\bh>.
+
+ Since different system calls have different return types, a prototype of
+ _\b__\b_s\bsy\bys\bsc\bca\bal\bll\bl specifying the correct return type should be declared locally.
+ This is especially important for system calls returning larger-than-int
+ results.
+
+ The _\b__\b_s\bsy\bys\bsc\bca\bal\bll\bl form should be used when one or more of the parameters is a
+ 64-bit argument to ensure that argument alignment is correct. This
+ system call is useful for testing new system calls that do not have
+ entries in the C library.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ The return values are defined by the system call being invoked. In
+ general, for system calls returning _\bi_\bn_\bt, a 0 return value indicates
+ success. A -1 return value indicates an error, and an error code is
+ stored in _\be_\br_\br_\bn_\bo.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The predecessor of these functions, the former i\bin\bnd\bdi\bir\br() system call, first
+ appeared in Version 4 AT&T UNIX. The s\bsy\bys\bsc\bca\bal\bll\bl() function first appeared
+ in 3BSD.
+
+B\bBU\bUG\bGS\bS
+ There is no way to simulate system calls that have multiple return values
+ such as pipe(2).
+
+N\bNA\bAM\bME\bE
+ _\b__\b_t\btf\bfo\bor\brk\bk_\b_t\bth\bhr\bre\bea\bad\bd, _\b__\b_t\btf\bfo\bor\brk\bk - create a new kernel thread in the current
+ process
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\bun\bni\bis\bst\btd\bd.\b.h\bh>\b>
+
+ struct __tfork {
+ void *tf_tcb; /* TCB address for new thread */
+ pid_t *tf_tid; /* where to write child's thread ID */
+ void *tf_stack; /* stack address for new thread */
+ };
+
+ _\bp_\bi_\bd_\b__\bt
+ _\b__\b_t\btf\bfo\bor\brk\bk_\b_t\bth\bhr\bre\bea\bad\bd(_\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\b__\b__\bt_\bf_\bo_\br_\bk _\b*_\bp_\ba_\br_\ba_\bm_\bs, _\bs_\bi_\bz_\be_\b__\bt _\bp_\bs_\bi_\bz_\be,
+ _\bv_\bo_\bi_\bd _\b(_\b*_\bs_\bt_\ba_\br_\bt_\bf_\bu_\bn_\bc_\b)_\b(_\bv_\bo_\bi_\bd _\b*_\b), _\bv_\bo_\bi_\bd _\b*_\bs_\bt_\ba_\br_\bt_\ba_\br_\bg);
+
+ _\bp_\bi_\bd_\b__\bt
+ _\b__\b_t\btf\bfo\bor\brk\bk(_\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\b__\b__\bt_\bf_\bo_\br_\bk _\b*_\bp_\ba_\br_\ba_\bm_\bs, _\bs_\bi_\bz_\be_\b__\bt _\bp_\bs_\bi_\bz_\be);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The _\b__\b_t\btf\bfo\bor\brk\bk_\b_t\bth\bhr\bre\bea\bad\bd() function creates a new kernel thread in the current
+ process. The new thread starts by calling _\bs_\bt_\ba_\br_\bt_\bf_\bu_\bn_\bc, passing _\bs_\bt_\ba_\br_\bt_\ba_\br_\bg as
+ the only argument. If _\bs_\bt_\ba_\br_\bt_\bf_\bu_\bn_\bc returns, the thread will exit.
+
+ The _\bp_\ba_\br_\ba_\bm_\bs argument provides parameters used by the kernel during thread
+ creation. The new thread's thread control block (TCB) address is set to
+ _\bt_\bf_\b__\bt_\bc_\bb. If _\bt_\bf_\b__\bt_\bi_\bd is not NULL, the new thread's thread ID is returned to
+ the user at that address, with the guarantee that this is done before
+ returning to userspace in either the calling thread or the new thread.
+ If _\bt_\bf_\b__\bs_\bt_\ba_\bc_\bk is not NULL, the new thread's stack is initialized to start
+ at that address. On hppa and hppa64, that is the lowest address used; on
+ other architectures that is the address after the highest address used.
+
+ The _\bp_\bs_\bi_\bz_\be argument provides the size of the _\bs_\bt_\br_\bu_\bc_\bt _\b__\b__\bt_\bf_\bo_\br_\bk passed via the
+ _\bp_\ba_\br_\ba_\bm_\bs argument.
+
+ The underlying system call used to create the thread is _\b__\b_t\btf\bfo\bor\brk\bk().
+ Because the new thread returns without a stack frame, the syscall cannot
+ be directly used from C and is therefore not provided as a function.
+ However, the syscall may show up in the output of kdump(1).
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ Upon successful completion, _\b__\b_t\btf\bfo\bor\brk\bk_\b_t\bth\bhr\bre\bea\bad\bd() returns in the calling
+ thread the thread ID of new thread. The _\b__\b_t\btf\bfo\bor\brk\bk() syscall itself, on
+ success, returns a value of 0 in the new thread and returns the thread ID
+ of the new thread to the calling thread. Otherwise, a value of -1 is
+ returned, no thread is created, and the global variable _\be_\br_\br_\bn_\bo is set to
+ indicate an error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ _\b__\b_t\btf\bfo\bor\brk\bk_\b_t\bth\bhr\bre\bea\bad\bd() and _\b__\b_t\btf\bfo\bor\brk\bk() will fail and no thread will be created
+ if:
+
+ [ENOMEM] Cannot allocate memory. The new process image
+ required more memory than was allowed by the hardware
+ or by system-imposed memory management constraints. A
+ lack of swap space is normally temporary; however, a
+ lack of core is not. Soft limits may be increased to
+ their corresponding hard limits.
+
+ [EINVAL] Invalid argument. Some invalid argument was supplied.
+
+ [EAGAIN] Resource temporarily unavailable. The system-imposed
+ limit on the total number of threads under execution
+ would be exceeded. This limit is configuration-
+ dependent.
+
+ [EAGAIN] Resource temporarily unavailable. The system-imposed
+ limit MAXUPRC on the total number of threads under
+ execution by a single user would be exceeded. MAXUPRC
+ is currently defined in <_\bs_\by_\bs_\b/_\bp_\ba_\br_\ba_\bm_\b._\bh> as CHILD_MAX,
+ which is currently defined as 80 in <_\bs_\by_\bs_\b/_\bs_\by_\bs_\bl_\bi_\bm_\bi_\bt_\bs_\b._\bh>.
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The _\b__\b_t\btf\bfo\bor\brk\bk_\b_t\bth\bhr\bre\bea\bad\bd() function and _\b__\b_t\btf\bfo\bor\brk\bk() syscall are specific to
+ OpenBSD and should not be used in portable applications.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The _\b__\b_t\btf\bfo\bor\brk\bk_\b_t\bth\bhr\bre\bea\bad\bd() function and _\b__\b_t\btf\bfo\bor\brk\bk() syscall appeared in
+ OpenBSD 5.1.
+
+N\bNA\bAM\bME\bE
+ _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt - synchronously accept a signal
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bsi\big\bgn\bna\bal\bl.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/t\bti\bim\bme\be.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt(_\bs_\bi_\bg_\bs_\be_\bt_\b__\bt _\bs_\be_\bt, _\bs_\bi_\bg_\bi_\bn_\bf_\bo_\b__\bt _\b*_\bi_\bn_\bf_\bo,
+ _\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\bt_\bi_\bm_\be_\bs_\bp_\be_\bc _\b*_\bt_\bi_\bm_\be_\bo_\bu_\bt);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() function is used to implement s\bsi\big\bgw\bwa\bai\bit\bt(). It selects
+ a signal pending for the calling thread or process from _\bs_\be_\bt, atomically
+ clears it from that set of pending signals, and returns that signal
+ number. If prior to the call to _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() there are multiple
+ pending instances of a single signal number, it is undefined whether upon
+ successful return there are any remaining pending signals for that signal
+ number. If no signal in _\bs_\be_\bt is pending at the time of the call, the
+ thread shall be suspended until one or more becomes pending. The signals
+ defined by _\bs_\be_\bt should have been blocked in all threads in the process at
+ the time of the call to _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt(); otherwise the signal may be
+ delivered to some thread that does not have it blocked.
+
+ If more than one thread is using _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() to wait for the same
+ signal, no more than one of these threads shall return from
+ _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() for any given signal that is sent. Which thread returns
+ from _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() if more than a single thread is waiting is
+ unspecified.
+
+ If the _\bi_\bn_\bf_\bo argument is not NULL, then a _\bs_\bi_\bg_\bi_\bn_\bf_\bo_\b__\bt will be stored there
+ which has the selected signal number in its _\bs_\bi_\b__\bs_\bi_\bg_\bn_\bo member and the cause
+ of the signal in its _\bs_\bi_\b__\bc_\bo_\bd_\be member.
+
+ If the _\bt_\bi_\bm_\be_\bo_\bu_\bt argument is not NULL and no selected signal is currently
+ pending, then _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() will wait no longer than the specified
+ time period for a signal to arrive before failing.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ If successful, the number of the signal that was accepted is returned.
+ Otherwise, a value of -1 is returned and errno is set to indicate the
+ error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() will succeed unless:
+
+ [EWOULDBLOCK] The timeout was reached before a selected signal was
+ received.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ sigaction(2), sigprocmask(2), sigwait(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The _\b__\b_t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() function is specific to OpenBSD and should not be
+ used in portable applications.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ A t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() syscall appeared in OpenBSD 3.9. The _\bi_\bn_\bf_\bo and _\bt_\bi_\bm_\be_\bo_\bu_\bt
+ arguments were added in OpenBSD 4.9.
+
+A\bAU\bUT\bTH\bHO\bOR\bRS\bS
+ The t\bth\bhr\brs\bsi\big\bgd\bdi\biv\bve\ber\brt\bt() syscall was created by Ted Unangst <_\bt_\be_\bd_\bu_\b@_\bO_\bp_\be_\bn_\bB_\bS_\bD_\b._\bo_\br_\bg>.
+ This manual page was written by Philip Guenther <_\bg_\bu_\be_\bn_\bt_\bh_\be_\br_\b@_\bO_\bp_\be_\bn_\bB_\bS_\bD_\b._\bo_\br_\bg>.
+
+N\bNA\bAM\bME\bE
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp, _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp - userspace thread sleep and wakeup
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/t\bti\bim\bme\be.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp(_\bc_\bo_\bn_\bs_\bt _\bv_\bo_\bl_\ba_\bt_\bi_\bl_\be _\bv_\bo_\bi_\bd _\b*_\bi_\bd, _\bc_\bl_\bo_\bc_\bk_\bi_\bd_\b__\bt _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd,
+ _\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\bt_\bi_\bm_\be_\bs_\bp_\be_\bc _\b*_\ba_\bb_\bs_\bt_\bi_\bm_\be, _\bv_\bo_\bi_\bd _\b*_\bl_\bo_\bc_\bk, _\bc_\bo_\bn_\bs_\bt _\bi_\bn_\bt _\b*_\ba_\bb_\bo_\br_\bt);
+
+ _\bi_\bn_\bt
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp(_\bc_\bo_\bn_\bs_\bt _\bv_\bo_\bl_\ba_\bt_\bi_\bl_\be _\bv_\bo_\bi_\bd _\b*_\bi_\bd, _\bi_\bn_\bt _\bc_\bo_\bu_\bn_\bt);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() and _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() functions provide thread sleep and
+ wakeup primitives with which synchronization primitives such as mutexes
+ and condition variables can be implemented. _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() blocks the
+ calling thread on the abstract ``wait channel'' identified by the _\bi_\bd
+ argument until another thread calls _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() with the same _\bi_\bd value.
+ If the _\ba_\bb_\bs_\bt_\bi_\bm_\be argument is not NULL, then it specifies an absolute time,
+ measured against the _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd clock, after which _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() should time
+ out and return. If the specified time is in the past then _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp()
+ will return immediately without blocking.
+
+ The _\bl_\bo_\bc_\bk argument, if not NULL, points to a locked spinlock that will be
+ unlocked by _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() atomically with respect to calls to
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp(), such that if another thread locks the spinlock before
+ calling _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() with the same _\bi_\bd, then the thread that called
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() will be eligible for being woken up and unblocked.
+
+ The _\ba_\bb_\bo_\br_\bt argument, if not NULL, points to an _\bi_\bn_\bt that will be examined
+ after unlocking the spinlock pointed to by _\bl_\bo_\bc_\bk and immediately before
+ blocking. If that _\bi_\bn_\bt is non-zero then _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() will immediately
+ return EINTR without blocking. This provides a mechanism for a signal
+ handler to keep a call to _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() from blocking, even if the signal
+ is delivered immediately before the call.
+
+ The _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() function unblocks one or more threads that are sleeping
+ on the wait channel identified by _\bi_\bd. The number of threads unblocked is
+ specified by the _\bc_\bo_\bu_\bn_\bt argument, except that if zero is specified then
+ all threads sleeping on that _\bi_\bd are unblocked.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() will return zero if woken by a matching call to
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp(), otherwise an error number will be returned to indicate the
+ error.
+
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() will return zero if at least one matching call to
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() was unblocked, otherwise an error number will be returned to
+ indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() and _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() will fail if:
+
+ [EINVAL] The _\bi_\bd_\be_\bn_\bt argument is NULL.
+
+ In addition, _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() may return one of the following errors:
+
+ [EWOULDBLOCK] The time specified by the _\ba_\bb_\bs_\bt_\bi_\bm_\be and _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd
+ arguments was reached.
+
+ [EINTR] A signal arrived or the _\ba_\bb_\bo_\br_\bt argument pointed to a
+ non-zero value.
+
+ [EINVAL] The _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd argument is neither CLOCK_REALTIME nor
+ CLOCK_MONOTONIC.
+
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() may return the following error:
+
+ [ESRCH] No threads calling _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() with the same _\bi_\bd were
+ found.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ pthread_cond_wait(3), pthread_mutex_lock(3), tsleep(9)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() and _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() functions are specific to OpenBSD and
+ should not be used in portable applications.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The t\bth\bhr\brs\bsl\ble\bee\bep\bp() and t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() syscalls appeared in OpenBSD 3.9. The
+ _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd and _\ba_\bb_\bs_\bt_\bi_\bm_\be arguments were added in OpenBSD 4.9. The functions
+ were renamed to _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() and _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() and the _\ba_\bb_\bo_\br_\bt argument was
+ added in OpenBSD 5.1
+
+A\bAU\bUT\bTH\bHO\bOR\bRS\bS
+ The t\bth\bhr\brs\bsl\ble\bee\bep\bp() and t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() syscalls were created by Ted Unangst
+ <_\bt_\be_\bd_\bu_\b@_\bO_\bp_\be_\bn_\bB_\bS_\bD_\b._\bo_\br_\bg>. This manual page was written by Philip Guenther
+ <_\bg_\bu_\be_\bn_\bt_\bh_\be_\br_\b@_\bO_\bp_\be_\bn_\bB_\bS_\bD_\b._\bo_\br_\bg>.
+
+N\bNA\bAM\bME\bE
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp, _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp - userspace thread sleep and wakeup
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/t\bti\bim\bme\be.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp(_\bc_\bo_\bn_\bs_\bt _\bv_\bo_\bl_\ba_\bt_\bi_\bl_\be _\bv_\bo_\bi_\bd _\b*_\bi_\bd, _\bc_\bl_\bo_\bc_\bk_\bi_\bd_\b__\bt _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd,
+ _\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\bt_\bi_\bm_\be_\bs_\bp_\be_\bc _\b*_\ba_\bb_\bs_\bt_\bi_\bm_\be, _\bv_\bo_\bi_\bd _\b*_\bl_\bo_\bc_\bk, _\bc_\bo_\bn_\bs_\bt _\bi_\bn_\bt _\b*_\ba_\bb_\bo_\br_\bt);
+
+ _\bi_\bn_\bt
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp(_\bc_\bo_\bn_\bs_\bt _\bv_\bo_\bl_\ba_\bt_\bi_\bl_\be _\bv_\bo_\bi_\bd _\b*_\bi_\bd, _\bi_\bn_\bt _\bc_\bo_\bu_\bn_\bt);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() and _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() functions provide thread sleep and
+ wakeup primitives with which synchronization primitives such as mutexes
+ and condition variables can be implemented. _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() blocks the
+ calling thread on the abstract ``wait channel'' identified by the _\bi_\bd
+ argument until another thread calls _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() with the same _\bi_\bd value.
+ If the _\ba_\bb_\bs_\bt_\bi_\bm_\be argument is not NULL, then it specifies an absolute time,
+ measured against the _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd clock, after which _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() should time
+ out and return. If the specified time is in the past then _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp()
+ will return immediately without blocking.
+
+ The _\bl_\bo_\bc_\bk argument, if not NULL, points to a locked spinlock that will be
+ unlocked by _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() atomically with respect to calls to
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp(), such that if another thread locks the spinlock before
+ calling _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() with the same _\bi_\bd, then the thread that called
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() will be eligible for being woken up and unblocked.
+
+ The _\ba_\bb_\bo_\br_\bt argument, if not NULL, points to an _\bi_\bn_\bt that will be examined
+ after unlocking the spinlock pointed to by _\bl_\bo_\bc_\bk and immediately before
+ blocking. If that _\bi_\bn_\bt is non-zero then _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() will immediately
+ return EINTR without blocking. This provides a mechanism for a signal
+ handler to keep a call to _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() from blocking, even if the signal
+ is delivered immediately before the call.
+
+ The _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() function unblocks one or more threads that are sleeping
+ on the wait channel identified by _\bi_\bd. The number of threads unblocked is
+ specified by the _\bc_\bo_\bu_\bn_\bt argument, except that if zero is specified then
+ all threads sleeping on that _\bi_\bd are unblocked.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() will return zero if woken by a matching call to
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp(), otherwise an error number will be returned to indicate the
+ error.
+
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() will return zero if at least one matching call to
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() was unblocked, otherwise an error number will be returned to
+ indicate the error.
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() and _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() will fail if:
+
+ [EINVAL] The _\bi_\bd_\be_\bn_\bt argument is NULL.
+
+ In addition, _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() may return one of the following errors:
+
+ [EWOULDBLOCK] The time specified by the _\ba_\bb_\bs_\bt_\bi_\bm_\be and _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd
+ arguments was reached.
+
+ [EINTR] A signal arrived or the _\ba_\bb_\bo_\br_\bt argument pointed to a
+ non-zero value.
+
+ [EINVAL] The _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd argument is neither CLOCK_REALTIME nor
+ CLOCK_MONOTONIC.
+
+ _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() may return the following error:
+
+ [ESRCH] No threads calling _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() with the same _\bi_\bd were
+ found.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ pthread_cond_wait(3), pthread_mutex_lock(3), tsleep(9)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() and _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() functions are specific to OpenBSD and
+ should not be used in portable applications.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The t\bth\bhr\brs\bsl\ble\bee\bep\bp() and t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() syscalls appeared in OpenBSD 3.9. The
+ _\bc_\bl_\bo_\bc_\bk_\b__\bi_\bd and _\ba_\bb_\bs_\bt_\bi_\bm_\be arguments were added in OpenBSD 4.9. The functions
+ were renamed to _\b__\b_t\bth\bhr\brs\bsl\ble\bee\bep\bp() and _\b__\b_t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() and the _\ba_\bb_\bo_\br_\bt argument was
+ added in OpenBSD 5.1
+
+A\bAU\bUT\bTH\bHO\bOR\bRS\bS
+ The t\bth\bhr\brs\bsl\ble\bee\bep\bp() and t\bth\bhr\brw\bwa\bak\bke\beu\bup\bp() syscalls were created by Ted Unangst
+ <_\bt_\be_\bd_\bu_\b@_\bO_\bp_\be_\bn_\bB_\bS_\bD_\b._\bo_\br_\bg>. This manual page was written by Philip Guenther
+ <_\bg_\bu_\be_\bn_\bt_\bh_\be_\br_\b@_\bO_\bp_\be_\bn_\bB_\bS_\bD_\b._\bo_\br_\bg>.
+
+N\bNA\bAM\bME\bE
+ _\b_e\bex\bxi\bit\bt, _\b_E\bEx\bxi\bit\bt - terminate the calling process
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\bun\bni\bis\bst\btd\bd.\b.h\bh>\b>
+
+ _\bv_\bo_\bi_\bd
+ _\b_e\bex\bxi\bit\bt(_\bi_\bn_\bt _\bs_\bt_\ba_\bt_\bu_\bs);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bst\btd\bdl\bli\bib\bb.\b.h\bh>\b>
+
+ _\bv_\bo_\bi_\bd
+ _\b_E\bEx\bxi\bit\bt(_\bi_\bn_\bt _\bs_\bt_\ba_\bt_\bu_\bs);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The _\b_e\bex\bxi\bit\bt() and _\b_E\bEx\bxi\bit\bt() functions terminate a process with the following
+ consequences:
+
+ +\b+\bo\bo All threads in the process are terminated.
+
+ +\b+\bo\bo All open file descriptors in the calling process are closed. This
+ may entail delays; for example, waiting for output to drain. A
+ process in this state may not be killed, as it is already dying.
+
+ +\b+\bo\bo If the parent process of the calling process has an outstanding
+ wait(2) call or catches the SIGCHLD signal, it is notified of the
+ calling process's termination and _\bs_\bt_\ba_\bt_\bu_\bs is set as defined by
+ wait(2). (Note that typically only the lower 8 bits of _\bs_\bt_\ba_\bt_\bu_\bs are
+ passed on to the parent, thus negative values have less meaning.)
+
+ +\b+\bo\bo The parent process ID of all of the calling process's existing child
+ processes are set to 1; the initialization process (see the
+ DEFINITIONS section of intro(2)) inherits each of these processes.
+
+ +\b+\bo\bo If the termination of the process causes any process group to become
+ orphaned (usually because the parents of all members of the group
+ have now exited; see Orphaned Process Group in intro(2)), and if any
+ member of the orphaned group is stopped, the SIGHUP and SIGCONT
+ signals are sent to all members of the newly orphaned process group.
+
+ +\b+\bo\bo If the process is a controlling process (see intro(2)), the SIGHUP
+ signal is sent to the foreground process group of the controlling
+ terminal, and all current access to the controlling terminal is
+ revoked.
+
+ Most C programs call the library routine exit(3), which flushes buffers,
+ closes streams, unlinks temporary files, etc., and then calls _\b_e\bex\bxi\bit\bt().
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ _\b_e\bex\bxi\bit\bt() and _\b_E\bEx\bxi\bit\bt() can never return.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ fork(2), intro(2), sigaction(2), wait(2), exit(3), sysexits(3)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The _\b_e\bex\bxi\bit\bt() function conform to IEEE Std 1003.1-2008 (``POSIX.1''). The
+ _\b_E\bEx\bxi\bit\bt() function conforms to ISO/IEC 9899:1999 (``ISO C99'').
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ An e\bex\bxi\bit\bt() system call first appeared in Version 1 AT&T UNIX. It accepts
+ the _\bs_\bt_\ba_\bt_\bu_\bs argument since Version 2 AT&T UNIX. An _\b_e\bex\bxi\bit\bt() variant first
+ appeared in Version 7 AT&T UNIX. The _\b_E\bEx\bxi\bit\bt() function appeared in
+ OpenBSD 3.6.
+
+N\bNA\bAM\bME\bE
+ a\bac\bcc\bce\bep\bpt\bt, a\bac\bcc\bce\bep\bpt\bt4\b4 - accept a connection on a socket
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bso\boc\bck\bke\bet\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ a\bac\bcc\bce\bep\bpt\bt(_\bi_\bn_\bt _\bs, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bo_\bc_\bk_\ba_\bd_\bd_\br _\b*_\ba_\bd_\bd_\br, _\bs_\bo_\bc_\bk_\bl_\be_\bn_\b__\bt _\b*_\ba_\bd_\bd_\br_\bl_\be_\bn);
+
+ _\bi_\bn_\bt
+ a\bac\bcc\bce\bep\bpt\bt4\b4(_\bi_\bn_\bt _\bs, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bo_\bc_\bk_\ba_\bd_\bd_\br _\b*_\ba_\bd_\bd_\br, _\bs_\bo_\bc_\bk_\bl_\be_\bn_\b__\bt _\b*_\ba_\bd_\bd_\br_\bl_\be_\bn, _\bi_\bn_\bt _\bf_\bl_\ba_\bg_\bs);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The argument _\bs is a socket that has been created with socket(2), bound to
+ an address with bind(2), and is listening for connections after a
+ listen(2). The a\bac\bcc\bce\bep\bpt\bt() call extracts the first connection request on
+ the queue of pending connections, creates a new socket with the same non-
+ blocking I/O mode as _\bs, and allocates a new file descriptor for the
+ socket with the close-on-exec flag clear.
+
+ The a\bac\bcc\bce\bep\bpt\bt4\b4() system call is similar, however the non-blocking I/O mode
+ of the new socket is determined by the SOCK_NONBLOCK flag in the _\bf_\bl_\ba_\bg_\bs
+ argument and the close-on-exec flag on the new file descriptor is
+ determined by the SOCK_CLOEXEC flag in the _\bf_\bl_\ba_\bg_\bs argument.
+
+ If no pending connections are present on the queue, and the socket is not
+ marked as non-blocking, a\bac\bcc\bce\bep\bpt\bt() blocks the caller until a connection is
+ present. If the socket is marked non-blocking and no pending connections
+ are present on the queue, a\bac\bcc\bce\bep\bpt\bt() returns an error as described below.
+ The accepted socket may not be used to accept more connections. The
+ original socket _\bs remains open.
+
+ The argument _\ba_\bd_\bd_\br is a result parameter that is filled in with the
+ address of the connecting entity as known to the communications layer.
+ The exact format of the _\ba_\bd_\bd_\br parameter is determined by the domain in
+ which the communication is occurring. The structure sockaddr_storage
+ exists for greater portability. It is large enough to hold any of the
+ types that may be returned in the _\ba_\bd_\bd_\br parameter.
+
+ The _\ba_\bd_\bd_\br_\bl_\be_\bn is a value-result parameter; it should initially contain the
+ amount of space pointed to by _\ba_\bd_\bd_\br; on return it will contain the actual
+ length (in bytes) of the address returned. If _\ba_\bd_\bd_\br_\bl_\be_\bn does not point to
+ enough space to hold the entire socket address, the result will be
+ truncated to the initial value of _\ba_\bd_\bd_\br_\bl_\be_\bn (in bytes). This call is used
+ with connection-based socket types, currently with SOCK_STREAM.
+
+ It is possible to select(2) or poll(2) a socket for the purposes of doing
+ an a\bac\bcc\bce\bep\bpt\bt() by selecting it for read.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ The call returns -1 on error. If it succeeds, it returns a non-negative
+ integer that is a descriptor for the accepted socket.
+
+E\bEX\bXA\bAM\bMP\bPL\bLE\bES\bS
+ The following code uses struct sockaddr_storage to allocate enough space
+ for the returned address:
+
+ #include <sys/types.h>
+ #include <sys/socket.h>
+
+ struct sockaddr_storage addr;
+ socklen_t len = sizeof(addr);
+ int retcode;
+
+ retcode = accept(s, (struct sockaddr *)&addr, &len);
+ if (retcode == -1)
+ err(1, "accept");
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ a\bac\bcc\bce\bep\bpt\bt() and a\bac\bcc\bce\bep\bpt\bt4\b4() will fail if:
+
+ [EBADF] The descriptor is invalid.
+
+ [ENOTSOCK] The descriptor doesn't reference a socket.
+
+ [EOPNOTSUPP] The referenced socket is not of type SOCK_STREAM.
+
+ [EINTR] A signal was caught before a connection arrived.
+
+ [EINVAL] The referenced socket is not listening for connections
+ (that is, listen(2) has not yet been called).
+
+ [EFAULT] The _\ba_\bd_\bd_\br or _\ba_\bd_\bd_\br_\bl_\be_\bn parameter is not in a valid part
+ of the process address space.
+
+ [EWOULDBLOCK] The socket is marked non-blocking and no connections
+ are present to be accepted.
+
+ [EMFILE] The per-process descriptor table is full.
+
+ [ENFILE] The system file table is full.
+
+ [ECONNABORTED] A connection has been aborted.
+
+ In addition, a\bac\bcc\bce\bep\bpt\bt4\b4() will fail if
+
+ [EINVAL] _\bf_\bl_\ba_\bg_\bs is invalid.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ bind(2), connect(2), listen(2), poll(2), select(2), socket(2)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The a\bac\bcc\bce\bep\bpt\bt() function conforms to IEEE Std 1003.1-2008 (``POSIX.1'').
+ The a\bac\bcc\bce\bep\bpt\bt4\b4() function is expected to conform to a future revision of
+ that standard.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The a\bac\bcc\bce\bep\bpt\bt() system call first appeared in 4.1cBSD and a\bac\bcc\bce\bep\bpt\bt4\b4() in
+ OpenBSD 5.7.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ When EMFILE or ENFILE is returned, new connections are neither dequeued
+ nor discarded. Thus considerable care is required in select(2) and
+ poll(2) loops.
+
+N\bNA\bAM\bME\bE
+ a\bac\bcc\bce\bep\bpt\bt, a\bac\bcc\bce\bep\bpt\bt4\b4 - accept a connection on a socket
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/s\bso\boc\bck\bke\bet\bt.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ a\bac\bcc\bce\bep\bpt\bt(_\bi_\bn_\bt _\bs, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bo_\bc_\bk_\ba_\bd_\bd_\br _\b*_\ba_\bd_\bd_\br, _\bs_\bo_\bc_\bk_\bl_\be_\bn_\b__\bt _\b*_\ba_\bd_\bd_\br_\bl_\be_\bn);
+
+ _\bi_\bn_\bt
+ a\bac\bcc\bce\bep\bpt\bt4\b4(_\bi_\bn_\bt _\bs, _\bs_\bt_\br_\bu_\bc_\bt _\bs_\bo_\bc_\bk_\ba_\bd_\bd_\br _\b*_\ba_\bd_\bd_\br, _\bs_\bo_\bc_\bk_\bl_\be_\bn_\b__\bt _\b*_\ba_\bd_\bd_\br_\bl_\be_\bn, _\bi_\bn_\bt _\bf_\bl_\ba_\bg_\bs);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The argument _\bs is a socket that has been created with socket(2), bound to
+ an address with bind(2), and is listening for connections after a
+ listen(2). The a\bac\bcc\bce\bep\bpt\bt() call extracts the first connection request on
+ the queue of pending connections, creates a new socket with the same non-
+ blocking I/O mode as _\bs, and allocates a new file descriptor for the
+ socket with the close-on-exec flag clear.
+
+ The a\bac\bcc\bce\bep\bpt\bt4\b4() system call is similar, however the non-blocking I/O mode
+ of the new socket is determined by the SOCK_NONBLOCK flag in the _\bf_\bl_\ba_\bg_\bs
+ argument and the close-on-exec flag on the new file descriptor is
+ determined by the SOCK_CLOEXEC flag in the _\bf_\bl_\ba_\bg_\bs argument.
+
+ If no pending connections are present on the queue, and the socket is not
+ marked as non-blocking, a\bac\bcc\bce\bep\bpt\bt() blocks the caller until a connection is
+ present. If the socket is marked non-blocking and no pending connections
+ are present on the queue, a\bac\bcc\bce\bep\bpt\bt() returns an error as described below.
+ The accepted socket may not be used to accept more connections. The
+ original socket _\bs remains open.
+
+ The argument _\ba_\bd_\bd_\br is a result parameter that is filled in with the
+ address of the connecting entity as known to the communications layer.
+ The exact format of the _\ba_\bd_\bd_\br parameter is determined by the domain in
+ which the communication is occurring. The structure sockaddr_storage
+ exists for greater portability. It is large enough to hold any of the
+ types that may be returned in the _\ba_\bd_\bd_\br parameter.
+
+ The _\ba_\bd_\bd_\br_\bl_\be_\bn is a value-result parameter; it should initially contain the
+ amount of space pointed to by _\ba_\bd_\bd_\br; on return it will contain the actual
+ length (in bytes) of the address returned. If _\ba_\bd_\bd_\br_\bl_\be_\bn does not point to
+ enough space to hold the entire socket address, the result will be
+ truncated to the initial value of _\ba_\bd_\bd_\br_\bl_\be_\bn (in bytes). This call is used
+ with connection-based socket types, currently with SOCK_STREAM.
+
+ It is possible to select(2) or poll(2) a socket for the purposes of doing
+ an a\bac\bcc\bce\bep\bpt\bt() by selecting it for read.
+
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+ The call returns -1 on error. If it succeeds, it returns a non-negative
+ integer that is a descriptor for the accepted socket.
+
+E\bEX\bXA\bAM\bMP\bPL\bLE\bES\bS
+ The following code uses struct sockaddr_storage to allocate enough space
+ for the returned address:
+
+ #include <sys/types.h>
+ #include <sys/socket.h>
+
+ struct sockaddr_storage addr;
+ socklen_t len = sizeof(addr);
+ int retcode;
+
+ retcode = accept(s, (struct sockaddr *)&addr, &len);
+ if (retcode == -1)
+ err(1, "accept");
+
+E\bER\bRR\bRO\bOR\bRS\bS
+ a\bac\bcc\bce\bep\bpt\bt() and a\bac\bcc\bce\bep\bpt\bt4\b4() will fail if:
+
+ [EBADF] The descriptor is invalid.
+
+ [ENOTSOCK] The descriptor doesn't reference a socket.
+
+ [EOPNOTSUPP] The referenced socket is not of type SOCK_STREAM.
+
+ [EINTR] A signal was caught before a connection arrived.
+
+ [EINVAL] The referenced socket is not listening for connections
+ (that is, listen(2) has not yet been called).
+
+ [EFAULT] The _\ba_\bd_\bd_\br or _\ba_\bd_\bd_\br_\bl_\be_\bn parameter is not in a valid part
+ of the process address space.
+
+ [EWOULDBLOCK] The socket is marked non-blocking and no connections
+ are present to be accepted.
+
+ [EMFILE] The per-process descriptor table is full.
+
+ [ENFILE] The system file table is full.
+
+ [ECONNABORTED] A connection has been aborted.
+
+ In addition, a\bac\bcc\bce\bep\bpt\bt4\b4() will fail if
+
+ [EINVAL] _\bf_\bl_\ba_\bg_\bs is invalid.
+
+S\bSE\bEE\bE A\bAL\bLS\bSO\bO
+ bind(2), connect(2), listen(2), poll(2), select(2), socket(2)
+
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+ The a\bac\bcc\bce\bep\bpt\bt() function conforms to IEEE Std 1003.1-2008 (``POSIX.1'').
+ The a\bac\bcc\bce\bep\bpt\bt4\b4() function is expected to conform to a future revision of
+ that standard.
+
+H\bHI\bIS\bST\bTO\bOR\bRY\bY
+ The a\bac\bcc\bce\bep\bpt\bt() system call first appeared in 4.1cBSD and a\bac\bcc\bce\bep\bpt\bt4\b4() in
+ OpenBSD 5.7.
+
+C\bCA\bAV\bVE\bEA\bAT\bTS\bS
+ When EMFILE or ENFILE is returned, new connections are neither dequeued
+ nor discarded. Thus considerable care is required in select(2) and
+ poll(2) loops.
+
+N\bNA\bAM\bME\bE
+ a\bac\bcc\bce\bes\bss\bs, f\bfa\bac\bcc\bce\bes\bss\bsa\bat\bt - check access permissions of a file or pathname
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\bun\bni\bis\bst\btd\bd.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ a\bac\bcc\bce\bes\bss\bs(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bi_\bn_\bt _\ba_\bm_\bo_\bd_\be);
+
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<f\bfc\bcn\bnt\btl\bl.\b.h\bh>\b>
+ #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\bun\bni\bis\bst\btd\bd.\b.h\bh>\b>
+
+ _\bi_\bn_\bt
+ f\bfa\bac\bcc\bce\bes\bss\bsa\bat\bt(_\bi_\bn_\bt _\bf_\bd, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh, _\bi_\bn_\bt _\ba_\bm_\bo_\bd_\be, _\bi_\bn_\bt _\bf_\bl_\ba_\bg);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ The a\bac\bcc\bce\bes\bss\bs() function checks the accessibility of the file named by _\bp_\ba_\bt_\bh
+ for the access permissions indicated by _\ba_\bm_\bo_\bd_\be. The _\ba_\bm_\bo_\bd_\be argument is
+ either the bitwise OR of one or more of the access permissions to be
+ checked (R_OK for read permission, W_OK for write permission, and X_OK
+ for execute/search permission) or the existence test, F_OK. All
+ components of the pathname _\bp_\ba_\bt_\bh are checked for access permissions
+ (including F_OK).
+
+ The real user ID is used in place of the effective user ID and the real
+ group access list (including the real group ID) is used in place of the
+ effective ID for verifying permission.
+
+ If the invoking process has superuser privileges, a\bac\bcc\bce\bes\bss\bs() will always
+ indicate success for R_OK and W_OK, regardless of the actual file
+ permission bits. Likewise, for X_OK, if the file has&