spawn.h

title: spawn.h(7p)

text:
# spawn.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
spawn.h — spawn (ADVANCED REALTIME)

## SYNOPSIS

```
#include <spawn.h>
```

## DESCRIPTION
The <spawn.h> header shall define the posix_spawnattr_t and posix_spawn_file_actions_t types used in performing spawn operations.

The <spawn.h> header shall define the mode_t and pid_t types as described in <sys/types.h>.

The <spawn.h> header shall define the sigset_t type as described in <signal.h>.

The tag sched_param shall be declared as naming an incomplete structure type, the contents of which are described in the <sched.h> header.

The <spawn.h> header shall define the following symbolic constants for use as the flags that may be set in a posix_spawnattr_t object using the posix_spawnattr_setflags() function:

```
POSIX_SPAWN_RESETIDS
POSIX_SPAWN_SETPGROUP
POSIX_SPAWN_SETSCHEDPARAM
POSIX_SPAWN_SETSCHEDULER
POSIX_SPAWN_SETSIGDEF
POSIX_SPAWN_SETSIGMASK
```

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
int   posix_spawn(pid_t *restrict, const char *restrict,

          const posix_spawn_file_actions_t *,

          const posix_spawnattr_t *restrict, char *const [restrict],

          char *const [restrict]);
int   posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *,

          int);
int   posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *,

          int, int);
int   posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict,

          int, const char *restrict, int, mode_t);
int   posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
int   posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
int   posix_spawnattr_destroy(posix_spawnattr_t *);
int   posix_spawnattr_getflags(const posix_spawnattr_t *restrict,

          short *restrict);
int   posix_spawnattr_getpgroup(const posix_spawnattr_t *restrict,

          pid_t *restrict);
int   posix_spawnattr_getschedparam(const posix_spawnattr_t *restrict,

          struct sched_param *restrict);
int   posix_spawnattr_getschedpolicy(const posix_spawnattr_t *restrict,

          int *restrict);
int   posix_spawnattr_getsigdefault(const posix_spawnattr_t *restrict,

          sigset_t *restrict);
int   posix_spawnattr_getsigmask(const posix_spawnattr_t *restrict,

          sigset_t *restrict);
int   posix_spawnattr_init(posix_spawnattr_t *);
int   posix_spawnattr_setflags(posix_spawnattr_t *, short);
int   posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);

int   posix_spawnattr_setschedparam(posix_spawnattr_t *restrict,

          const struct sched_param *restrict);
int   posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
int   posix_spawnattr_setsigdefault(posix_spawnattr_t *restrict,

          const sigset_t *restrict);
int   posix_spawnattr_setsigmask(posix_spawnattr_t *restrict,

          const sigset_t *restrict);
int   posix_spawnp(pid_t *restrict, const char *restrict,

          const posix_spawn_file_actions_t *,

          const posix_spawnattr_t *restrict,

          char *const [restrict], char *const [restrict]);
```

Inclusion of the <spawn.h> header may make visible symbols defined in the <sched.h> and <signal.h> headers.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sched.h>, <semaphore.h>, <signal.h>, <sys_types.h>

The System Interfaces volume of POSIX.1‐2017, posix_spawn(), posix_spawn_file_actions_addclose(), posix_spawn_file_actions_adddup2(), posix_spawn_file_actions_destroy(), posix_spawnattr_destroy(), posix_spawnattr_getflags(), posix_spawnattr_getpgroup(), posix_spawnattr_getschedparam(), posix_spawnattr_getschedpolicy(), posix_spawnattr_getsigdefault(), posix_spawnattr_getsigmask()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


stdarg.h

package: man-pages-posix-devel

title: stdarg.h(7p)

text:
# stdarg.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
stdarg.h — handle variable argument list

## SYNOPSIS

```
#include <stdarg.h>
```

```
void va_start(va_list ap, argN);
void va_copy(va_list dest, va_list src);
type va_arg(va_list ap, type);
void va_end(va_list ap);
```

## DESCRIPTION
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1‐2017 defers to the ISO C standard.

The <stdarg.h> header shall contain a set of macros which allows portable functions that accept variable argument lists to be written. Functions that have variable argument lists (such as printf()) but do not use these macros are inherently non-portable, as different systems use different argument-passing conventions.

The <stdarg.h> header shall define the va_list type for variables used to traverse the list.

The va_start() macro is invoked to initialize ap to the beginning of the list before any calls to va_arg().

The va_copy() macro initializes dest as a copy of src, as if the va_start() macro had been applied to dest followed by the same sequence of uses of the va_arg() macro as had previously been used to reach the present state of src. Neither the va_copy() nor va_start() macro shall be invoked to reinitialize dest without an intervening invocation of the va_end() macro for the same dest.

The object ap may be passed as an argument to another function; if that function invokes the va_arg() macro with parameter ap, the value of ap in the calling function is unspecified and shall be passed to the va_end() macro prior to any further reference to ap. The parameter argN is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the ...). If the parameter argN is declared with the register storage class, with a function type or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined.

The va_arg() macro shall return the next argument in the list pointed to by ap. Each invocation of va_arg() modifies ap so that the values of successive arguments are returned in turn. The type parameter shall be a type name specified such that the type of a pointer to an object that has the specified type can be obtained simply by postfixing a '*' to type. If there is no actual next argument, or if type is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined, except for the following cases:

*

One type is a signed integer type, the other type is the corresponding unsigned integer type, and the value is representable in both types.

*

One type is a pointer to void and the other is a pointer to a character type.

*

Both types are pointers.

Different types can be mixed, but it is up to the routine to know what type of argument is expected.

The va_end() macro is used to clean up; it invalidates ap for use (unless va_start() or va_copy() is invoked again).

Each invocation of the va_start() and va_copy() macros shall be matched by a corresponding invocation of the va_end() macro in the same function.

Multiple traversals, each bracketed by va_start() ... va_end(), are possible.

The following sections are informative.

## EXAMPLES
This example is a possible implementation of execl():

```
#include <stdarg.h>
```

```
#define  MAXARGS     31
```

```
/*

 * execl is called by

 * execl(file, arg1, arg2, ..., (char *)(0));

 */
int execl(const char *file, const char *args, ...)
{

    va_list ap;

    char *array[MAXARGS +1];

    int argno = 0;
```

```
    va_start(ap, args);

    while (args != 0 && argno < MAXARGS)

    {

        array[argno++] = args;

        args = va_arg(ap, const char *);

    }

    array[argno] = (char *) 0;

    va_end(ap);

    return execv(file, array);
}
```

## APPLICATION USAGE
It is up to the calling routine to communicate to the called routine how many arguments there are, since it is not always possible for the called routine to determine this in any other way. For example, execl() is passed a null pointer to signal the end of the list. The printf() function can tell how many arguments are there by the format argument.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
The System Interfaces volume of POSIX.1‐2017, exec, fprintf()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


stdbool.h

title: stdbool.h(7p)

text:
# stdbool.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
stdbool.h — boolean type and values

## SYNOPSIS

```
#include <stdbool.h>
```

## DESCRIPTION
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1‐2017 defers to the ISO C standard.

The <stdbool.h> header shall define the following macros:

bool

Expands to _Bool.

true

Expands to the integer constant 1.

false

Expands to the integer constant 0.

__bool_true_false_are_defined

Expands to the integer constant 1.

An application may undefine and then possibly redefine the macros bool, true, and false.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
The ability to undefine and redefine the macros bool, true, and false is an obsolescent feature and may be removed in a future version.

## SEE ALSO
None.

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


stddef.h

title: stddef.h(7p)

text:
# stddef.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
stddef.h — standard type definitions

## SYNOPSIS

```
#include <stddef.h>
```

## DESCRIPTION
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1‐2017 defers to the ISO C standard.

The <stddef.h> header shall define the following macros:

NULL

Null pointer constant. The macro shall expand to an integer constant expression with the value 0 cast to type void *.

offsetof(type, member-designator)

Integer constant expression of type size_t, the value of which is the offset in bytes to the structure member (member-designator), from the beginning of its structure (type).

The <stddef.h> header shall define the following types:

ptrdiff_t

Signed integer type of the result of subtracting two pointers.

wchar_t

Integer type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales; the null character shall have the code value zero. Each member of the basic character set shall have a code value equal to its value when used as the lone character in an integer character constant if an implementation does not define __STDC_MB_MIGHT_NEQ_WC__.

size_t

Unsigned integer type of the result of the sizeof operator.

The implementation shall support one or more programming environments in which the widths of ptrdiff_t, size_t, and wchar_t are no greater than the width of type long. The names of these programming environments can be obtained using the confstr() function or the getconf utility.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
The ISO C standard does not require the NULL macro to include the cast to type void * and specifies that the NULL macro be implementation-defined. POSIX.1‐2008 requires the cast and therefore need not be implementation-defined.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_types.h>, <wchar.h>

The System Interfaces volume of POSIX.1‐2017, confstr()

The Shell and Utilities volume of POSIX.1‐2017, getconf

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


stdint.h

title: stdint.h(7p)

text:
# stdint.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
stdint.h — integer types

## SYNOPSIS

```
#include <stdint.h>
```

## DESCRIPTION
Some of the functionality described on this reference page extends the ISO C standard. Applications shall define the appropriate feature test macro (see the System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header.

The <stdint.h> header shall declare sets of integer types having specified widths, and shall define corresponding sets of macros. It shall also define macros that specify limits of integer types corresponding to types defined in other standard headers.

Note:

The ``width'' of an integer type is the number of bits used to store its value in a pure binary system; the actual type may use more bits than that (for example, a 28-bit type could be stored in 32 bits of actual storage). An N-bit signed type has values in the range -2N-1 or 1-2N-1 to 2N-1-1, while an N-bit unsigned type has values in the range 0 to 2N-1.

Types are defined in the following categories:

*

Integer types having certain exact widths

*

Integer types having at least certain specified widths

*

Fastest integer types having at least certain specified widths

*

Integer types wide enough to hold pointers to objects

*

Integer types having greatest width

(Some of these types may denote the same type.)

Corresponding macros specify limits of the declared types and construct suitable constants.

For each type described herein that the implementation provides, the <stdint.h> header shall declare that typedef name and define the associated macros. Conversely, for each type described herein that the implementation does not provide, the <stdint.h> header shall not declare that typedef name, nor shall it define the associated macros. An implementation shall provide those types described as required, but need not provide any of the others (described as optional).

### Integer Types
When typedef names differing only in the absence or presence of the initial u are defined, they shall denote corresponding signed and unsigned types as described in the ISO/IEC 9899:1999 standard, Section 6.2.5; an implementation providing one of these corresponding types shall also provide the other.

In the following descriptions, the symbol N represents an unsigned decimal integer with no leading zeros (for example, 8 or 24, but not 04 or 048).

*

Exact-width integer types

The typedef name intN_t designates a signed integer type with width N, no padding bits, and a two's-complement representation. Thus, int8_t denotes a signed integer type with a width of exactly 8 bits.

The typedef name uintN_t designates an unsigned integer type with width N. Thus, uint24_t denotes an unsigned integer type with a width of exactly 24 bits.

The following types are required:

```
int8_t
int16_t
int32_t
uint8_t
uint16_t
uint32_t
```

If an implementation provides integer types with width 64 that meet these requirements, then the following types are required: int64_t uint64_t

In particular, this will be the case if any of the following are true:

--

The implementation supports the _POSIX_V7_ILP32_OFFBIG programming environment and the application is being built in the _POSIX_V7_ILP32_OFFBIG programming environment (see the Shell and Utilities volume of POSIX.1‐2017, c99, Programming Environments).

--

The implementation supports the _POSIX_V7_LP64_OFF64 programming environment and the application is being built in the _POSIX_V7_LP64_OFF64 programming environment.

--

The implementation supports the _POSIX_V7_LPBIG_OFFBIG programming environment and the application is being built in the _POSIX_V7_LPBIG_OFFBIG programming environment.

All other types of this form are optional.

*

Minimum-width integer types

The typedef name int_leastN_t designates a signed integer type with a width of at least N, such that no signed integer type with lesser size has at least the specified width. Thus, int_least32_t denotes a signed integer type with a width of at least 32 bits.

The typedef name uint_leastN_t designates an unsigned integer type with a width of at least N, such that no unsigned integer type with lesser size has at least the specified width. Thus, uint_least16_t denotes an unsigned integer type with a width of at least 16 bits.

The following types are required: int_least8_t int_least16_t int_least32_t int_least64_t uint_least8_t uint_least16_t uint_least32_t uint_least64_t

All other types of this form are optional.

*

Fastest minimum-width integer types

Each of the following types designates an integer type that is usually fastest to operate with among all integer types that have at least the specified width.

The designated type is not guaranteed to be fastest for all purposes; if the implementation has no clear grounds for choosing one type over another, it will simply pick some integer type satisfying the signedness and width requirements.

The typedef name int_fastN_t designates the fastest signed integer type with a width of at least N. The typedef name uint_fastN_t designates the fastest unsigned integer type with a width of at least N.

The following types are required: int_fast8_t int_fast16_t int_fast32_t int_fast64_t uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t

All other types of this form are optional.

*

Integer types capable of holding object pointers

The following type designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to a pointer to void, and the result will compare equal to the original pointer: intptr_t

The following type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to a pointer to void, and the result will compare equal to the original pointer: uintptr_t

On XSI-conformant systems, the intptr_t and uintptr_t types are required; otherwise, they are optional.

*

Greatest-width integer types

The following type designates a signed integer type capable of representing any value of any signed integer type: intmax_t

The following type designates an unsigned integer type capable of representing any value of any unsigned integer type: uintmax_t

These types are required.

Note:

Applications can test for optional types by using the corresponding limit macro from Limits of Specified-Width Integer Types.

### Limits of Specified-Width Integer Types
The following macros specify the minimum and maximum limits of the types declared in the <stdint.h> header. Each macro name corresponds to a similar type name in Integer Types.

Each instance of any defined macro shall be replaced by a constant expression suitable for use in #if preprocessing directives, and this expression shall have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. Its implementation-defined value shall be equal to or greater in magnitude (absolute value) than the corresponding value given below, with the same sign, except where stated to be exactly the given value.

*

Limits of exact-width integer types

--

Minimum values of exact-width signed integer types:

{INTN_MIN}

Exactly -( 2^N-1 )

--

Maximum values of exact-width signed integer types:

{INTN_MAX}

Exactly 2^N-1 -1

--

Maximum values of exact-width unsigned integer types:

{UINTN_MAX}

Exactly 2^N -1

*

Limits of minimum-width integer types

--

Minimum values of minimum-width signed integer types:

{INT_LEASTN_MIN}

-( 2^N-1 -1)

--

Maximum values of minimum-width signed integer types:

{INT_LEASTN_MAX}

2^N-1 -1

--

Maximum values of minimum-width unsigned integer types:

{UINT_LEASTN_MAX}

2^N -1

*

Limits of fastest minimum-width integer types

--

Minimum values of fastest minimum-width signed integer types:

{INT_FASTN_MIN}

-( 2^N-1 -1)

--

Maximum values of fastest minimum-width signed integer types:

{INT_FASTN_MAX}

2^N-1 -1

--

Maximum values of fastest minimum-width unsigned integer types:

{UINT_FASTN_MAX}

2^N -1

*

Limits of integer types capable of holding object pointers

--

Minimum value of pointer-holding signed integer type:

{INTPTR_MIN}

-( 2^15 -1)

--

Maximum value of pointer-holding signed integer type:

{INTPTR_MAX}

2^15 -1

--

Maximum value of pointer-holding unsigned integer type:

{UINTPTR_MAX}

2^16 -1

*

Limits of greatest-width integer types

--

Minimum value of greatest-width signed integer type:

{INTMAX_MIN}

-( 2^63 -1)

--

Maximum value of greatest-width signed integer type:

{INTMAX_MAX}

2^63 -1

--

Maximum value of greatest-width unsigned integer type:

{UINTMAX_MAX}

2^64 -1

### Limits of Other Integer Types
The following macros specify the minimum and maximum limits of integer types corresponding to types defined in other standard headers.

Each instance of these macros shall be replaced by a constant expression suitable for use in #if preprocessing directives, and this expression shall have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. Its implementation-defined value shall be equal to or greater in magnitude (absolute value) than the corresponding value given below, with the same sign.

*

Limits of ptrdiff_t:

{PTRDIFF_MIN}

-65535

{PTRDIFF_MAX}

+65535

*

Limits of sig_atomic_t:

{SIG_ATOMIC_MIN}

See below.

{SIG_ATOMIC_MAX}

See below.

*

Limit of size_t:

{SIZE_MAX}

65535

*

Limits of wchar_t:

{WCHAR_MIN}

See below.

{WCHAR_MAX}

See below.

*

Limits of wint_t:

{WINT_MIN}

See below.

{WINT_MAX}

See below.

If sig_atomic_t (see the <signal.h> header) is defined as a signed integer type, the value of {SIG_ATOMIC_MIN} shall be no greater than -127 and the value of {SIG_ATOMIC_MAX} shall be no less than 127; otherwise, sig_atomic_t shall be defined as an unsigned integer type, and the value of {SIG_ATOMIC_MIN} shall be 0 and the value of {SIG_ATOMIC_MAX} shall be no less than 255.

If wchar_t (see the <stddef.h> header) is defined as a signed integer type, the value of {WCHAR_MIN} shall be no greater than -127 and the value of {WCHAR_MAX} shall be no less than 127; otherwise, wchar_t shall be defined as an unsigned integer type, and the value of {WCHAR_MIN} shall be 0 and the value of {WCHAR_MAX} shall be no less than 255.

If wint_t (see the <wchar.h> header) is defined as a signed integer type, the value of {WINT_MIN} shall be no greater than -32767 and the value of {WINT_MAX} shall be no less than 32767; otherwise, wint_t shall be defined as an unsigned integer type, and the value of {WINT_MIN} shall be 0 and the value of {WINT_MAX} shall be no less than 65535.

### Macros for Integer Constant Expressions
The following macros expand to integer constant expressions suitable for initializing objects that have integer types corresponding to types defined in the <stdint.h> header. Each macro name corresponds to a similar type name listed under Minimum-width integer types and Greatest-width integer types.

Each invocation of one of these macros shall expand to an integer constant expression suitable for use in #if preprocessing directives. The type of the expression shall have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. The value of the expression shall be that of the argument.

The argument in any instance of these macros shall be an unsuffixed integer constant with a value that does not exceed the limits for the corresponding type.

*

Macros for minimum-width integer constant expressions

The macro INTN_C(value) shall expand to an integer constant expression corresponding to the type int_leastN_t. The macro UINTN_C(value) shall expand to an integer constant expression corresponding to the type uint_leastN_t. For example, if uint_least64_t is a name for the type unsigned long long, then UINT64_C(0x123) might expand to the integer constant 0x123ULL.

*

Macros for greatest-width integer constant expressions

The following macro expands to an integer constant expression having the value specified by its argument and the type intmax_t: INTMAX_C(value)

The following macro expands to an integer constant expression having the value specified by its argument and the type uintmax_t: UINTMAX_C(value)

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
The <stdint.h> header is a subset of the <inttypes.h> header more suitable for use in freestanding environments, which might not support the formatted I/O functions. In some environments, if the formatted conversion support is not wanted, using this header instead of the <inttypes.h> header avoids defining such a large number of macros.

As a consequence of adding int8_t, the following are true:

*

A byte is exactly 8 bits.

*

{CHAR_BIT} has the value 8, {SCHAR_MAX} has the value 127, {SCHAR_MIN} has the value -128, and {UCHAR_MAX} has the value 255.

(The POSIX standard explicitly requires 8-bit char and two's-complement arithmetic.)

## FUTURE DIRECTIONS
typedef names beginning with int or uint and ending with _t may be added to the types defined in the <stdint.h> header. Macro names beginning with INT or UINT and ending with _MAX, _MIN, or _C may be added to the macros defined in the <stdint.h> header.

## SEE ALSO
<inttypes.h>, <signal.h>, <stddef.h>, <wchar.h>

The System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compilation Environment

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


stdio.h

title: stdio.h(7p)

text:
# stdio.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
stdio.h — standard buffered input/output

## SYNOPSIS

```
#include <stdio.h>
```

## DESCRIPTION
Some of the functionality described on this reference page extends the ISO C standard. Applications shall define the appropriate feature test macro (see the System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header.

The <stdio.h> header shall define the following data types through typedef:

FILE

A structure containing information about a file.

fpos_t

A non-array type containing all information needed to specify uniquely every position within a file.

off_t

As described in <sys/types.h>.

size_t

As described in <stddef.h>.

ssize_t

As described in <sys/types.h>.

va_list

As described in <stdarg.h>.

The <stdio.h> header shall define the following macros which shall expand to integer constant expressions:

BUFSIZ

Size of <stdio.h> buffers. This shall expand to a positive value.

L_ctermid

Maximum size of character array to hold ctermid() output.

L_tmpnam

Maximum size of character array to hold tmpnam() output.

The <stdio.h> header shall define the following macros which shall expand to integer constant expressions with distinct values:

_IOFBF

Input/output fully buffered.

_IOLBF

Input/output line buffered.

_IONBF

Input/output unbuffered.

The <stdio.h> header shall define the following macros which shall expand to integer constant expressions with distinct values:

SEEK_CUR

Seek relative to current position.

SEEK_END

Seek relative to end-of-file.

SEEK_SET

Seek relative to start-of-file.

The <stdio.h> header shall define the following macros which shall expand to integer constant expressions denoting implementation limits:

{FILENAME_MAX}

Maximum size in bytes of the longest pathname that the implementation guarantees can be opened.

{FOPEN_MAX}

Number of streams which the implementation guarantees can be open simultaneously. The value is at least eight.

{TMP_MAX}

Minimum number of unique filenames generated by tmpnam(). Maximum number of times an application can call tmpnam() reliably. The value of {TMP_MAX} is at least 25.

On XSI-conformant systems, the value of {TMP_MAX} is at least 10000.

The <stdio.h> header shall define the following macro which shall expand to an integer constant expression with type int and a negative value:

EOF

End-of-file return value.

The <stdio.h> header shall define NULL as described in <stddef.h>.

The <stdio.h> header shall define the following macro which shall expand to a string constant:

P_tmpdir

Default directory prefix for tempnam().

The <stdio.h> header shall define the following macros which shall expand to expressions of type ``pointer to FILE'' that point to the FILE objects associated, respectively, with the standard error, input, and output streams:

stderr

Standard error output stream.

stdin

Standard input stream.

stdout

Standard output stream.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
void     clearerr(FILE *);
char    *ctermid(char *);
int      dprintf(int, const char *restrict, ...)
int      fclose(FILE *);
FILE    *fdopen(int, const char *);
int      feof(FILE *);
int      ferror(FILE *);
int      fflush(FILE *);
int      fgetc(FILE *);
int      fgetpos(FILE *restrict, fpos_t *restrict);
char    *fgets(char *restrict, int, FILE *restrict);
int      fileno(FILE *);
void     flockfile(FILE *);
FILE    *fmemopen(void *restrict, size_t, const char *restrict);
FILE    *fopen(const char *restrict, const char *restrict);
int      fprintf(FILE *restrict, const char *restrict, ...);
int      fputc(int, FILE *);
int      fputs(const char *restrict, FILE *restrict);
size_t   fread(void *restrict, size_t, size_t, FILE *restrict);
FILE    *freopen(const char *restrict, const char *restrict,

             FILE *restrict);
int      fscanf(FILE *restrict, const char *restrict, ...);
int      fseek(FILE *, long, int);
int      fseeko(FILE *, off_t, int);
int      fsetpos(FILE *, const fpos_t *);
long     ftell(FILE *);
off_t    ftello(FILE *);
int      ftrylockfile(FILE *);
void     funlockfile(FILE *);
size_t   fwrite(const void *restrict, size_t, size_t, FILE *restrict);
int      getc(FILE *);
int      getchar(void);
int      getc_unlocked(FILE *);
int      getchar_unlocked(void);
ssize_t  getdelim(char **restrict, size_t *restrict, int,

             FILE *restrict);
ssize_t  getline(char **restrict, size_t *restrict, FILE *restrict);
char    *gets(char *);
FILE    *open_memstream(char **, size_t *);
int      pclose(FILE *);
void     perror(const char *);
FILE    *popen(const char *, const char *);
int      printf(const char *restrict, ...);
int      putc(int, FILE *);
int      putchar(int);
int      putc_unlocked(int, FILE *);
int      putchar_unlocked(int);
int      puts(const char *);
int      remove(const char *);
int      rename(const char *, const char *);
int      renameat(int, const char *, int, const char *);
void     rewind(FILE *);
int      scanf(const char *restrict, ...);
void     setbuf(FILE *restrict, char *restrict);
int      setvbuf(FILE *restrict, char *restrict, int, size_t);
int      snprintf(char *restrict, size_t, const char *restrict, ...);
int      sprintf(char *restrict, const char *restrict, ...);
int      sscanf(const char *restrict, const char *restrict, ...);
char    *tempnam(const char *, const char *);
FILE    *tmpfile(void);
char    *tmpnam(char *);
int      ungetc(int, FILE *);
int      vdprintf(int, const char *restrict, va_list);
int      vfprintf(FILE *restrict, const char *restrict, va_list);
int      vfscanf(FILE *restrict, const char *restrict, va_list);
int      vprintf(const char *restrict, va_list);
int      vscanf(const char *restrict, va_list);
int      vsnprintf(char *restrict, size_t, const char *restrict,

             va_list);
int      vsprintf(char *restrict, const char *restrict, va_list);
int      vsscanf(const char *restrict, const char *restrict, va_list);
```

Inclusion of the <stdio.h> header may also make visible all symbols from <stddef.h>.

The following sections are informative.

## APPLICATION USAGE
Since standard I/O streams may use an underlying file descriptor to access the file associated with a stream, application developers need to be aware that {FOPEN_MAX} streams may not be available if file descriptors are being used to access files that are not associated with streams.

## RATIONALE
There is a conflict between the ISO C standard and the POSIX definition of the {TMP_MAX} macro that is addressed by ISO/IEC 9899:1999 standard, Defect Report 336. The POSIX standard is in alignment with the public record of the response to the Defect Report. This change has not yet been published as part of the ISO C standard.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<stdarg.h>, <stddef.h>, <sys_types.h>

The System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compilation Environment, clearerr(), ctermid(), fclose(), fdopen(), feof(), ferror(), fflush(), fgetc(), fgetpos(), fgets(), fileno(), flockfile(), fmemopen(), fopen(), fprintf(), fputc(), fputs(), fread(), freopen(), fscanf(), fseek(), fsetpos(), ftell(), fwrite(), getc(), getchar(), getc_unlocked(), getdelim(), getopt(), gets(), open_memstream(), pclose(), perror(), popen(), putc(), putchar(), puts(), remove(), rename(), rewind(), setbuf(), setvbuf(), stdin, system(), tempnam(), tmpfile(), tmpnam(), ungetc(), vfprintf(), vfscanf()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


stdlib.h

title: stdlib.h(7p)

text:
# stdlib.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
stdlib.h — standard library definitions

## SYNOPSIS

```
#include <stdlib.h>
```

## DESCRIPTION
Some of the functionality described on this reference page extends the ISO C standard. Applications shall define the appropriate feature test macro (see the System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header.

The <stdlib.h> header shall define the following macros which shall expand to integer constant expressions:

EXIT_FAILURE

Unsuccessful termination for exit(); evaluates to a non-zero value.

EXIT_SUCCESS

Successful termination for exit(); evaluates to 0.

{RAND_MAX}

Maximum value returned by rand(); at least 32767.

The <stdlib.h> header shall define the following macro which shall expand to a positive integer expression with type size_t:

{MB_CUR_MAX}

Maximum number of bytes in a character specified by the current locale (category LC_CTYPE).

In the POSIX locale the value of {MB_CUR_MAX} shall be 1.

The <stdlib.h> header shall define NULL as described in <stddef.h>.

The <stdlib.h> header shall define the following data types through typedef:

div_t

Structure type returned by the div() function.

ldiv_t

Structure type returned by the ldiv() function.

lldiv_t

Structure type returned by the lldiv() function.

size_t

As described in <stddef.h>.

wchar_t

As described in <stddef.h>.

In addition, the <stdlib.h> header shall define the following symbolic constants and macros as described in <sys/wait.h>:

```
WEXITSTATUS
WIFEXITED
WIFSIGNALED
WIFSTOPPED
WNOHANG
WSTOPSIG
WTERMSIG
WUNTRACED
```

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
void          _Exit(int);
long          a64l(const char *);
void          abort(void);
int           abs(int);
int           atexit(void (*)(void));
double        atof(const char *);
int           atoi(const char *);
long          atol(const char *);
long long     atoll(const char *);
void         *bsearch(const void *, const void *, size_t, size_t,

                  int (*)(const void *, const void *));
void         *calloc(size_t, size_t);
div_t         div(int, int);
double        drand48(void);
double        erand48(unsigned short [3]);
void          exit(int);
void          free(void *);
char         *getenv(const char *);
int           getsubopt(char **, char *const *, char **);
int           grantpt(int);
char         *initstate(unsigned, char *, size_t);
long          jrand48(unsigned short [3]);
char         *l64a(long);
long          labs(long);
void          lcong48(unsigned short [7]);
ldiv_t        ldiv(long, long);
long long     llabs(long long);
lldiv_t       lldiv(long long, long long);
long          lrand48(void);
void         *malloc(size_t);
int           mblen(const char *, size_t);
size_t        mbstowcs(wchar_t *restrict, const char *restrict, size_t);
int           mbtowc(wchar_t *restrict, const char *restrict, size_t);
char         *mkdtemp(char *);
int           mkstemp(char *);
long          mrand48(void);
long          nrand48(unsigned short [3]);
int           posix_memalign(void **, size_t, size_t);
int           posix_openpt(int);
char         *ptsname(int);
int           putenv(char *);
void          qsort(void *, size_t, size_t, int (*)(const void *,

                  const void *));
int           rand(void);
int           rand_r(unsigned *);
long          random(void);
void         *realloc(void *, size_t);
char         *realpath(const char *restrict, char *restrict);
unsigned short *seed48(unsigned short [3]);
int           setenv(const char *, const char *, int);
void          setkey(const char *);
char         *setstate(char *);
void          srand(unsigned);
void          srand48(long);
void          srandom(unsigned);
double        strtod(const char *restrict, char **restrict);
float         strtof(const char *restrict, char **restrict);
long          strtol(const char *restrict, char **restrict, int);
long double   strtold(const char *restrict, char **restrict);
long long     strtoll(const char *restrict, char **restrict, int);
unsigned long strtoul(const char *restrict, char **restrict, int);
unsigned long long

              strtoull(const char *restrict, char **restrict, int);
int           system(const char *);
int           unlockpt(int);
int           unsetenv(const char *);
size_t        wcstombs(char *restrict, const wchar_t *restrict, size_t);
int           wctomb(char *, wchar_t);
```

Inclusion of the <stdlib.h> header may also make visible all symbols from <stddef.h>, <limits.h>, <math.h>, and <sys/wait.h>.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<limits.h>, <math.h>, <stddef.h>, <sys_types.h>, <sys_wait.h>

The System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compilation Environment, _Exit(), a64l(), abort(), abs(), atexit(), atof(), atoi(), atol(), bsearch(), calloc(), div(), drand48(), exit(), free(), getenv(), getsubopt(), grantpt(), initstate(), labs(), ldiv(), malloc(), mblen(), mbstowcs(), mbtowc(), mkdtemp(), posix_memalign(), posix_openpt(), ptsname(), putenv(), qsort(), rand(), realloc(), realpath(), setenv(), setkey(), strtod(), strtol(), strtoul(), system(), unlockpt(), unsetenv(), wcstombs(), wctomb()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


string.h

title: string.h(7p)

text:
# string.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
string.h — string operations

## SYNOPSIS

```
#include <string.h>
```

## DESCRIPTION
Some of the functionality described on this reference page extends the ISO C standard. Applications shall define the appropriate feature test macro (see the System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header.

The <string.h> header shall define NULL and size_t as described in <stddef.h>.

The <string.h> header shall define the locale_t type as described in <locale.h>.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided for use with ISO C standard compilers.

```
void    *memccpy(void *restrict, const void *restrict, int, size_t);
void    *memchr(const void *, int, size_t);
int      memcmp(const void *, const void *, size_t);
void    *memcpy(void *restrict, const void *restrict, size_t);
void    *memmove(void *, const void *, size_t);
void    *memset(void *, int, size_t);
char    *stpcpy(char *restrict, const char *restrict);
char    *stpncpy(char *restrict, const char *restrict, size_t);
char    *strcat(char *restrict, const char *restrict);
char    *strchr(const char *, int);
int      strcmp(const char *, const char *);
int      strcoll(const char *, const char *);
int      strcoll_l(const char *, const char *, locale_t);
char    *strcpy(char *restrict, const char *restrict);
size_t   strcspn(const char *, const char *);
char    *strdup(const char *);
char    *strerror(int);
char    *strerror_l(int, locale_t);
int      strerror_r(int, char *, size_t);
size_t   strlen(const char *);
char    *strncat(char *restrict, const char *restrict, size_t);
int      strncmp(const char *, const char *, size_t);
char    *strncpy(char *restrict, const char *restrict, size_t);
char    *strndup(const char *, size_t);
size_t   strnlen(const char *, size_t);
char    *strpbrk(const char *, const char *);
char    *strrchr(const char *, int);
char    *strsignal(int);
size_t   strspn(const char *, const char *);
char    *strstr(const char *, const char *);
char    *strtok(char *restrict, const char *restrict);
char    *strtok_r(char *restrict, const char *restrict, char **restrict);
size_t   strxfrm(char *restrict, const char *restrict, size_t);
size_t   strxfrm_l(char *restrict, const char *restrict,

             size_t, locale_t);
```

Inclusion of the <string.h> header may also make visible all symbols from <stddef.h>.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<locale.h>, <stddef.h>, <sys_types.h>

The System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compilation Environment, memccpy(), memchr(), memcmp(), memcpy(), memmove(), memset(), strcat(), strchr(), strcmp(), strcoll(), strcpy(), strcspn(), strdup(), strerror(), strlen(), strncat(), strncmp(), strncpy(), strpbrk(), strrchr(), strsignal(), strspn(), strstr(), strtok(), strxfrm()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


strings.h

title: strings.h(7p)

text:
# strings.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
strings.h — string operations

## SYNOPSIS

```
#include <strings.h>
```

## DESCRIPTION
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided for use with ISO C standard compilers.

```
int    ffs(int);
int    strcasecmp(const char *, const char *);
int    strcasecmp_l(const char *, const char *, locale_t);
int    strncasecmp(const char *, const char *, size_t);
int    strncasecmp_l(const char *, const char *, size_t, locale_t);
```

The <strings.h> header shall define the locale_t type as described in <locale.h>.

The <strings.h> header shall define the size_t type as described in <sys/types.h>.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<locale.h>, <sys_types.h>

The System Interfaces volume of POSIX.1‐2017, ffs(), strcasecmp()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


stropts.h

title: stropts.h(7p)

text:
# stropts.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
stropts.h — STREAMS interface (STREAMS)

## SYNOPSIS

```
#include <stropts.h>
```

## DESCRIPTION
The <stropts.h> header shall define the bandinfo structure, which shall include at least the following members:

```
int            bi_flag  Flushing type.
unsigned char  bi_pri   Priority band.
```

The <stropts.h> header shall define the strpeek structure, which shall include at least the following members:

```
struct strbuf  ctlbuf   The control portion of the message.
struct strbuf  databuf  The data portion of the message.
t_uscalar_t    flags    RS_HIPRI or 0.
```

The <stropts.h> header shall define the strbuf structure, which shall include at least the following members:

```
char  *buf     Pointer to buffer.
int    len     Length of data.
int    maxlen  Maximum buffer length.
```

The <stropts.h> header shall define the strfdinsert structure, which shall include at least the following members:

```
struct strbuf  ctlbuf   The control portion of the message.
struct strbuf  databuf  The data portion of the message.
int            fildes   File descriptor of the other STREAM.
t_uscalar_t    flags    RS_HIPRI or 0.
int            offset   Relative location of the stored value.
```

The <stropts.h> header shall define the strioctl structure, which shall include at least the following members:

```
int    ic_cmd     ioctl() command.
char  *ic_dp      Pointer to buffer.
int    ic_len     Length of data.
int    ic_timout  Timeout for response.
```

The <stropts.h> header shall define the strrecvfd structure, which shall include at least the following members:

```
int    fd   Received file descriptor.
gid_t  gid  GID of sender.
uid_t  uid  UID of sender.
```

The <stropts.h> header shall define the uid_t and gid_t types through typedef, as described in <sys/types.h>.

The <stropts.h> header shall define the t_scalar_t and t_uscalar_t types, respectively, as signed and unsigned opaque types of equal length of at least 32 bits.

The <stropts.h> header shall define the str_list structure, which shall include at least the following members:

```
struct str_mlist  *sl_modlist  STREAMS module names.
int                sl_nmods    Number of STREAMS module names.
```

The <stropts.h> header shall define the str_mlist structure, which shall include at least the following member:

```
char  l_name[FMNAMESZ+1]  A STREAMS module name.
```

The <stropts.h> header shall define at least the following symbolic constants for use as the request argument to ioctl():

I_ATMARK

Is the top message ``marked''?

I_CANPUT

Is a band writable?

I_CKBAND

See if any messages exist in a band.

I_FDINSERT

Send implementation-defined information about another STREAM.

I_FIND

Look for a STREAMS module.

I_FLUSH

Flush a STREAM.

I_FLUSHBAND

Flush one band of a STREAM.

I_GETBAND

Get the band of the top message on a STREAM.

I_GETCLTIME

Get close time delay.

I_GETSIG

Retrieve current notification signals.

I_GRDOPT

Get the read mode.

I_GWROPT

Get the write mode.

I_LINK

Connect two STREAMs.

I_LIST

Get all the module names on a STREAM.

I_LOOK

Get the top module name.

I_NREAD

Size the top message.

I_PEEK

Peek at the top message on a STREAM.

I_PLINK

Persistently connect two STREAMs.

I_POP

Pop a STREAMS module.

I_PUNLINK

Dismantle a persistent STREAMS link.

I_PUSH

Push a STREAMS module.

I_RECVFD

Get a file descriptor sent via I_SENDFD.

I_SENDFD

Pass a file descriptor through a STREAMS pipe.

I_SETCLTIME

Set close time delay.

I_SETSIG

Ask for notification signals.

I_SRDOPT

Set the read mode.

I_STR

Send a STREAMS ioctl().

I_SWROPT

Set the write mode.

I_UNLINK

Disconnect two STREAMs.

The <stropts.h> header shall define at least the following symbolic constant for use with I_LOOK:

FMNAMESZ

The minimum size in bytes of the buffer referred to by the arg argument.

The <stropts.h> header shall define at least the following symbolic constants for use with I_FLUSH:

FLUSHR

Flush read queues.

FLUSHRW

Flush read and write queues.

FLUSHW

Flush write queues.

The <stropts.h> header shall define at least the following symbolic constants for use with I_SETSIG:

S_BANDURG

When used in conjunction with S_RDBAND, SIGURG is generated instead of SIGPOLL when a priority message reaches the front of the STREAM head read queue.

S_ERROR

Notification of an error condition reaches the STREAM head.

S_HANGUP

Notification of a hangup reaches the STREAM head.

S_HIPRI

A high-priority message is present on a STREAM head read queue.

S_INPUT

A message, other than a high-priority message, has arrived at the head of a STREAM head read queue.

S_MSG

A STREAMS signal message that contains the SIGPOLL signal reaches the front of the STREAM head read queue.

S_OUTPUT

The write queue for normal data (priority band 0) just below the STREAM head is no longer full. This notifies the process that there is room on the queue for sending (or writing) normal data downstream.

S_RDBAND

A message with a non-zero priority band has arrived at the head of a STREAM head read queue.

S_RDNORM

A normal (priority band set to 0) message has arrived at the head of a STREAM head read queue.

S_WRBAND

The write queue for a non-zero priority band just below the STREAM head is no longer full.

S_WRNORM

Equivalent to S_OUTPUT.

The <stropts.h> header shall define at least the following symbolic constant for use with I_PEEK:

RS_HIPRI

Only look for high-priority messages.

The <stropts.h> header shall define at least the following symbolic constants for use with I_SRDOPT:

RMSGD

Message-discard mode.

RMSGN

Message-non-discard mode.

RNORM

Byte-STREAM mode, the default.

RPROTDAT

Deliver the control part of a message as data when a process issues a read().

RPROTDIS

Discard the control part of a message, delivering any data part, when a process issues a read().

RPROTNORM

Fail read() with [EBADMSG] if a message containing a control part is at the front of the STREAM head read queue.

The <stropts.h> header shall define at least the following symbolic constant for use with I_SWOPT:

SNDZERO

Send a zero-length message downstream when a write() of 0 bytes occurs.

The <stropts.h> header shall define at least the following symbolic constants for use with I_ATMARK:

ANYMARK

Check if the message is marked.

LASTMARK

Check if the message is the last one marked on the queue.

The <stropts.h> header shall define at least the following symbolic constant for use with I_UNLINK:

MUXID_ALL

Unlink all STREAMs linked to the STREAM associated with fildes.

The <stropts.h> header shall define the following symbolic constants for getmsg(), getpmsg(), putmsg(), and putpmsg():

MORECTL

More control information is left in message.

MOREDATA

More data is left in message.

MSG_ANY

Receive any message.

MSG_BAND

Receive message from specified band.

MSG_HIPRI

Send/receive high-priority message.

The <stropts.h> header may make visible all of the symbols from <unistd.h>.

The <stropts.h> header may also define macros for message types using names that start with M_.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
int    fattach(int, const char *);
int    fdetach(const char *);
int    getmsg(int, struct strbuf *restrict, struct strbuf *restrict,

           int *restrict);
int    getpmsg(int, struct strbuf *restrict, struct strbuf *restrict,

           int *restrict, int *restrict);
int    ioctl(int, int, ...);
int    isastream(int);
int    putmsg(int, const struct strbuf *, const struct strbuf *, int);
int    putpmsg(int, const struct strbuf *, const struct strbuf *, int,

           int);
```

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_types.h>, <unistd.h>

The System Interfaces volume of POSIX.1‐2017, close(), fattach(), fcntl(), fdetach(), getmsg(), ioctl(), isastream(), open(), pipe(), read(), poll(), putmsg(), signal(), write()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


title: sys_ipc.h(7p)

text:
# sys_ipc.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
sys/ipc.h — XSI interprocess communication access structure

## SYNOPSIS

```
#include <sys/ipc.h>
```

## DESCRIPTION
The <sys/ipc.h> header is used by three mechanisms for XSI interprocess communication (IPC): messages, semaphores, and shared memory. All use a common structure type, ipc_perm, to pass information used in determining permission to perform an IPC operation.

The <sys/ipc.h> header shall define the ipc_perm structure, which shall include the following members:

```
uid_t    uid    Owner's user ID.
gid_t    gid    Owner's group ID.
uid_t    cuid   Creator's user ID.
gid_t    cgid   Creator's group ID.
mode_t   mode   Read/write permission.
```

The <sys/ipc.h> header shall define the uid_t, gid_t, mode_t, and key_t types as described in <sys/types.h>.

The <sys/ipc.h> header shall define the following symbolic constants.

Mode bits:

IPC_CREAT

Create entry if key does not exist.

IPC_EXCL

Fail if key exists.

IPC_NOWAIT

Error if request must wait.

Keys:

IPC_PRIVATE

Private key.

Control commands:

IPC_RMID

Remove identifier.

IPC_SET

Set options.

IPC_STAT

Get options.

The following shall be declared as a function and may also be defined as a macro. A function prototype shall be provided.

```
key_t  ftok(const char *, int);
```

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_types.h>

The System Interfaces volume of POSIX.1‐2017, ftok()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


title: sys_mman.h(7p)

text:
# sys_mman.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
sys/mman.h — memory management declarations

## SYNOPSIS

```
#include <sys/mman.h>
```

## DESCRIPTION
The <sys/mman.h> header shall define the following symbolic constants for use as protection options:

PROT_EXEC

Page can be executed.

PROT_NONE

Page cannot be accessed.

PROT_READ

Page can be read.

PROT_WRITE

Page can be written.

The <sys/mman.h> header shall define the following symbolic constants for use as flag options:

MAP_FIXED

Interpret addr exactly.

MAP_PRIVATE

Changes are private.

MAP_SHARED

Share changes.

The <sys/mman.h> header shall define the following symbolic constants for the msync() function:

MS_ASYNC

Perform asynchronous writes.

MS_INVALIDATE

Invalidate mappings.

MS_SYNC

Perform synchronous writes.

The <sys/mman.h> header shall define the following symbolic constants for the mlockall() function:

MCL_CURRENT

Lock currently mapped pages.

MCL_FUTURE

Lock pages that become mapped.

The <sys/mman.h> header shall define the symbolic constant MAP_FAILED which shall have type void * and shall be used to indicate a failure from the mmap() function .

If the Advisory Information option is supported, the <sys/mman.h> header shall define symbolic constants for the advice argument to the posix_madvise() function as follows:

POSIX_MADV_DONTNEED

The application expects that it will not access the specified range in the near future.

POSIX_MADV_NORMAL

The application has no advice to give on its behavior with respect to the specified range. It is the default characteristic if no advice is given for a range of memory.

POSIX_MADV_RANDOM

The application expects to access the specified range in a random order.

POSIX_MADV_SEQUENTIAL

The application expects to access the specified range sequentially from lower addresses to higher addresses.

POSIX_MADV_WILLNEED

The application expects to access the specified range in the near future.

The <sys/mman.h> header shall define the following symbolic constants for use as flags for the posix_typed_mem_open() function:

POSIX_TYPED_MEM_ALLOCATE

Allocate on mmap().

POSIX_TYPED_MEM_ALLOCATE_CONTIG

Allocate contiguously on mmap().

POSIX_TYPED_MEM_MAP_ALLOCATABLE

Map on mmap(), without affecting allocatability.

The <sys/mman.h> header shall define the mode_t, off_t, and size_t types as described in <sys_types.h>.

The <sys/mman.h> header shall define the posix_typed_mem_info structure, which shall include at least the following member:

```
size_t  posix_tmi_length  Maximum length which may be allocated

                          from a typed memory object.
```

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
int    mlock(const void *, size_t);
int    mlockall(int);
void  *mmap(void *, size_t, int, int, int, off_t);
int    mprotect(void *, size_t, int);
int    msync(void *, size_t, int);
int    munlock(const void *, size_t);
int    munlockall(void);
int    munmap(void *, size_t);
int    posix_madvise(void *, size_t, int);
int    posix_mem_offset(const void *restrict, size_t, off_t *restrict,

           size_t *restrict, int *restrict);
int    posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
int    posix_typed_mem_open(const char *, int, int);
int    shm_open(const char *, int, mode_t);
int    shm_unlink(const char *);
```

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_types.h>

The System Interfaces volume of POSIX.1‐2017, mlock(), mlockall(), mmap(), mprotect(), msync(), munmap(), posix_madvise(), posix_mem_offset(), posix_typed_mem_get_info(), posix_typed_mem_open(), shm_open(), shm_unlink()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


title: sys_msg.h(7p)

text:
# sys_msg.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
sys/msg.h — XSI message queue structures

## SYNOPSIS

```
#include <sys/msg.h>
```

## DESCRIPTION
The <sys/msg.h> header shall define the following data types through typedef:

msgqnum_t

Used for the number of messages in the message queue.

msglen_t

Used for the number of bytes allowed in a message queue.

These types shall be unsigned integer types that are able to store values at least as large as a type unsigned short.

The <sys/msg.h> header shall define the following symbolic constant as a message operation flag:

MSG_NOERROR

No error if big message.

The <sys/msg.h> header shall define the msqid_ds structure, which shall include the following members:

```
struct ipc_perm msg_perm   Operation permission structure.
msgqnum_t       msg_qnum   Number of messages currently on queue.
msglen_t        msg_qbytes Maximum number of bytes allowed on queue.
pid_t           msg_lspid  Process ID of last msgsnd().
pid_t           msg_lrpid  Process ID of last msgrcv().
time_t          msg_stime  Time of last msgsnd().
time_t          msg_rtime  Time of last msgrcv().
time_t          msg_ctime  Time of last change.
```

The <sys/msg.h> header shall define the pid_t, size_t, ssize_t, and time_t types as described in <sys/types.h>.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
int       msgctl(int, int, struct msqid_ds *);
int       msgget(key_t, int);
ssize_t   msgrcv(int, void *, size_t, long, int);
int       msgsnd(int, const void *, size_t, int);
```

In addition, the <sys/msg.h> header shall include the <sys/ipc.h> header.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_ipc.h>, <sys_types.h>

The System Interfaces volume of POSIX.1‐2017, msgctl(), msgget(), msgrcv(), msgsnd()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


title: sys_resource.h(7p)

text:
# sys_resource.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
sys/resource.h — definitions for XSI resource operations

## SYNOPSIS

```
#include <sys/resource.h>
```

## DESCRIPTION
The <sys/resource.h> header shall define the following symbolic constants as possible values of the which argument of getpriority() and setpriority():

PRIO_PROCESS

Identifies the who argument as a process ID.

PRIO_PGRP

Identifies the who argument as a process group ID.

PRIO_USER

Identifies the who argument as a user ID.

The <sys/resource.h> header shall define the following type through typedef:

rlim_t

Unsigned integer type used for limit values.

The <sys/resource.h> header shall define the following symbolic constants, which shall have values suitable for use in #if preprocessing directives:

RLIM_INFINITY

A value of rlim_t indicating no limit.

RLIM_SAVED_MAX

A value of type rlim_t indicating an unrepresentable saved hard limit.

RLIM_SAVED_CUR

A value of type rlim_t indicating an unrepresentable saved soft limit.

On implementations where all resource limits are representable in an object of type rlim_t, RLIM_SAVED_MAX and RLIM_SAVED_CUR need not be distinct from RLIM_INFINITY.

The <sys/resource.h> header shall define the following symbolic constants as possible values of the who parameter of getrusage():

RUSAGE_SELF

Returns information about the current process.

RUSAGE_CHILDREN

Returns information about children of the current process.

The <sys/resource.h> header shall define the rlimit structure, which shall include at least the following members:

```
rlim_t rlim_cur  The current (soft) limit.
rlim_t rlim_max  The hard limit.
```

The <sys/resource.h> header shall define the rusage structure, which shall include at least the following members:

```
struct timeval ru_utime  User time used.
struct timeval ru_stime  System time used.
```

The <sys/resource.h> header shall define the timeval structure as described in <sys/time.h>.

The <sys/resource.h> header shall define the following symbolic constants as possible values for the resource argument of getrlimit() and setrlimit():

RLIMIT_CORE

Limit on size of core file.

RLIMIT_CPU

Limit on CPU time per process.

RLIMIT_DATA

Limit on data segment size.

RLIMIT_FSIZE

Limit on file size.

RLIMIT_NOFILE

Limit on number of open files.

RLIMIT_STACK

Limit on stack size.

RLIMIT_AS

Limit on address space size.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
int  getpriority(int, id_t);
int  getrlimit(int, struct rlimit *);
int  getrusage(int, struct rusage *);
int  setpriority(int, id_t, int);
int  setrlimit(int, const struct rlimit *);
```

The <sys/resource.h> header shall define the id_t type through typedef, as described in <sys/types.h>.

Inclusion of the <sys/resource.h> header may also make visible all symbols from <sys/time.h>.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_time.h>, <sys_types.h>

The System Interfaces volume of POSIX.1‐2017, getpriority(), getrlimit(), getrusage()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


title: sys_select.h(7p)

text:
# sys_select.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
sys/select.h — select types

## SYNOPSIS

```
#include <sys/select.h>
```

## DESCRIPTION
The <sys/select.h> header shall define the timeval structure, which shall include at least the following members:

```
time_t         tv_sec      Seconds.
suseconds_t    tv_usec     Microseconds.
```

The <sys/select.h> header shall define the time_t and suseconds_t types as described in <sys/types.h>.

The <sys/select.h> header shall define the sigset_t type as described in <signal.h>.

The <sys/select.h> header shall define the timespec structure as described in <time.h>.

The <sys/select.h> header shall define the fd_set type as a structure.

The <sys/select.h> header shall define the following symbolic constant, which shall have a value suitable for use in #if preprocessing directives:

FD_SETSIZE

Maximum number of file descriptors in an fd_set structure.

The following shall be declared as functions, defined as macros, or both. If functions are declared, function prototypes shall be provided.

```
void FD_CLR(int, fd_set *);
int  FD_ISSET(int, fd_set *);
void FD_SET(int, fd_set *);
void FD_ZERO(fd_set *);
```

If implemented as macros, these may evaluate their arguments more than once, so applications should ensure that the arguments they supply are never expressions with side-effects.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
int  pselect(int, fd_set *restrict, fd_set *restrict, fd_set *restrict,

         const struct timespec *restrict, const sigset_t *restrict);
int  select(int, fd_set *restrict, fd_set *restrict, fd_set *restrict,

         struct timeval *restrict);
```

Inclusion of the <sys/select.h> header may make visible all symbols from the headers <signal.h> and <time.h>.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<signal.h>, <sys_time.h>, <sys_types.h>, <time.h>

The System Interfaces volume of POSIX.1‐2017, pselect()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


title: sys_sem.h(7p)

text:
# sys_sem.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
sys/sem.h — XSI semaphore facility

## SYNOPSIS

```
#include <sys/sem.h>
```

## DESCRIPTION
The <sys/sem.h> header shall define the following symbolic constant for use as a semaphore operation flag:

SEM_UNDO

Set up adjust on exit entry.

The <sys/sem.h> header shall define the following symbolic constants for use as commands for the semctl() function:

GETNCNT

Get semncnt.

GETPID

Get sempid.

GETVAL

Get semval.

GETALL

Get all cases of semval.

GETZCNT

Get semzcnt.

SETVAL

Set semval.

SETALL

Set all cases of semval.

The <sys/sem.h> header shall define the semid_ds structure, which shall include the following members:

```
struct ipc_perm  sem_perm  Operation permission structure.
unsigned short   sem_nsems Number of semaphores in set.
time_t           sem_otime Last semop() time.
time_t           sem_ctime Last time changed by semctl().
```

The <sys/sem.h> header shall define the pid_t, size_t, and time_t types as described in <sys/types.h>.

A semaphore shall be represented by an anonymous structure, which shall include the following members:

```
unsigned short  semval   Semaphore value.
pid_t           sempid   Process ID of last operation.
unsigned short  semncnt  Number of processes waiting for semval

                         to become greater than current value.
unsigned short  semzcnt  Number of processes waiting for semval

                         to become 0.
```

The <sys/sem.h> header shall define the sembuf structure, which shall include the following members:

```
unsigned short  sem_num   Semaphore number.
short           sem_op    Semaphore operation.
short           sem_flg   Operation flags.
```

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
int   semctl(int, int, int, ...);
int   semget(key_t, int, int);
int   semop(int, struct sembuf *, size_t);
```

In addition, the <sys/sem.h> header shall include the <sys/ipc.h> header.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_ipc.h>, <sys_types.h>

The System Interfaces volume of POSIX.1‐2017, semctl(), semget(), semop()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


title: sys_shm.h(7p)

text:
# sys_shm.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
sys/shm.h — XSI shared memory facility

## SYNOPSIS

```
#include <sys/shm.h>
```

## DESCRIPTION
The <sys/shm.h> header shall define the following symbolic constants:

SHM_RDONLY

Attach read-only (else read-write).

SHM_RND

Round attach address to SHMLBA.

SHMLBA

Segment low boundary address multiple.

The <sys/shm.h> header shall define the following data types through typedef:

shmatt_t

Unsigned integer used for the number of current attaches that must be able to store values at least as large as a type unsigned short.

The <sys/shm.h> header shall define the shmid_ds structure, which shall include the following members:

```
struct ipc_perm shm_perm   Operation permission structure.
size_t          shm_segsz  Size of segment in bytes.
pid_t           shm_lpid   Process ID of last shared memory operation.
pid_t           shm_cpid   Process ID of creator.
shmatt_t        shm_nattch Number of current attaches.
time_t          shm_atime  Time of last shmat().
time_t          shm_dtime  Time of last shmdt().
time_t          shm_ctime  Time of last change by shmctl().
```

The <sys/shm.h> header shall define the pid_t, size_t, and time_t types as described in <sys/types.h>.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
void *shmat(int, const void *, int);
int   shmctl(int, int, struct shmid_ds *);
int   shmdt(const void *);
int   shmget(key_t, size_t, int);
```

In addition, the <sys/shm.h> header shall include the <sys/ipc.h> header.

The following sections are informative.

## APPLICATION USAGE
None.

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_ipc.h>, <sys_types.h>

The System Interfaces volume of POSIX.1‐2017, shmat(), shmctl(), shmdt(), shmget()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


title: sys_socket.h(7p)

text:
# sys_socket.h(7p)

## PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

## NAME
sys/socket.h — main sockets header

## SYNOPSIS

```
#include <sys/socket.h>
```

## DESCRIPTION
The <sys/socket.h> header shall define the socklen_t type, which is an integer type of width of at least 32 bits; see APPLICATION USAGE.

The <sys/socket.h> header shall define the sa_family_t unsigned integer type.

The <sys/socket.h> header shall define the sockaddr structure, which shall include at least the following members:

```
sa_family_t  sa_family  Address family.
char         sa_data[]  Socket address (variable-length data).
```

The sockaddr structure is used to define a socket address which is used in the bind(), connect(), getpeername(), getsockname(), recvfrom(), and sendto() functions.

The <sys/socket.h> header shall define the sockaddr_storage structure, which shall be:

*

Large enough to accommodate all supported protocol-specific address structures

*

Aligned at an appropriate boundary so that pointers to it can be cast as pointers to protocol-specific address structures and used to access the fields of those structures without alignment problems

The sockaddr_storage structure shall include at least the following members:

```
sa_family_t   ss_family
```

When a pointer to a sockaddr_storage structure is cast as a pointer to a sockaddr structure, the ss_family field of the sockaddr_storage structure shall map onto the sa_family field of the sockaddr structure. When a pointer to a sockaddr_storage structure is cast as a pointer to a protocol-specific address structure, the ss_family field shall map onto a field of that structure that is of type sa_family_t and that identifies the protocol's address family.

The <sys/socket.h> header shall define the msghdr structure, which shall include at least the following members:

```
void          *msg_name        Optional address.
socklen_t      msg_namelen     Size of address.
struct iovec  *msg_iov         Scatter/gather array.
int            msg_iovlen      Members in msg_iov.
void          *msg_control     Ancillary data; see below.
socklen_t      msg_controllen  Ancillary data buffer len.
int            msg_flags       Flags on received message.
```

The msghdr structure is used to minimize the number of directly supplied parameters to the recvmsg() and sendmsg() functions. This structure is used as a value‐result parameter in the recvmsg() function and value only for the sendmsg() function.

The <sys/socket.h> header shall define the iovec structure as described in <sys/uio.h>.

The <sys/socket.h> header shall define the cmsghdr structure, which shall include at least the following members:

```
socklen_t  cmsg_len    Data byte count, including the cmsghdr.
int        cmsg_level  Originating protocol.
int        cmsg_type   Protocol-specific type.
```

The cmsghdr structure is used for storage of ancillary data object information.

Ancillary data consists of a sequence of pairs, each consisting of a cmsghdr structure followed by a data array. The data array contains the ancillary data message, and the cmsghdr structure contains descriptive information that allows an application to correctly parse the data.

The values for cmsg_level shall be legal values for the level argument to the getsockopt() and setsockopt() functions. The system documentation shall specify the cmsg_type definitions for the supported protocols.

Ancillary data is also possible at the socket level. The <sys/socket.h> header shall define the following symbolic constant for use as the cmsg_type value when cmsg_level is SOL_SOCKET:

SCM_RIGHTS

Indicates that the data array contains the access rights to be sent or received.

The <sys/socket.h> header shall define the following macros to gain access to the data arrays in the ancillary data associated with a message header:

CMSG_DATA(cmsg)

If the argument is a pointer to a cmsghdr structure, this macro shall return an unsigned character pointer to the data array associated with the cmsghdr structure.

CMSG_NXTHDR(mhdr,cmsg)

If the first argument is a pointer to a msghdr structure and the second argument is a pointer to a cmsghdr structure in the ancillary data pointed to by the msg_control field of that msghdr structure, this macro shall return a pointer to the next cmsghdr structure, or a null pointer if this structure is the last cmsghdr in the ancillary data.

CMSG_FIRSTHDR(mhdr)

If the argument is a pointer to a msghdr structure, this macro shall return a pointer to the first cmsghdr structure in the ancillary data associated with this msghdr structure, or a null pointer if there is no ancillary data associated with the msghdr structure.

The <sys/socket.h> header shall define the linger structure, which shall include at least the following members:

```
int  l_onoff   Indicates whether linger option is enabled.
int  l_linger  Linger time, in seconds.
```

The <sys/socket.h> header shall define the following symbolic constants with distinct values:

SOCK_DGRAM

Datagram socket.

SOCK_RAW

Raw Protocol Interface.

SOCK_SEQPACKET

Sequenced-packet socket.

SOCK_STREAM

Byte-stream socket.

The <sys/socket.h> header shall define the following symbolic constant for use as the level argument of setsockopt() and getsockopt().

SOL_SOCKET

Options to be accessed at socket level, not protocol level.

The <sys/socket.h> header shall define the following symbolic constants with distinct values for use as the option_name argument in getsockopt() or setsockopt() calls (see the System Interfaces volume of POSIX.1‐2017, Section 2.10.16, Use of Options):

SO_ACCEPTCONN

Socket is accepting connections.

SO_BROADCAST

Transmission of broadcast messages is supported.

SO_DEBUG

Debugging information is being recorded.

SO_DONTROUTE

Bypass normal routing.

SO_ERROR

Socket error status.

SO_KEEPALIVE

Connections are kept alive with periodic messages.

SO_LINGER

Socket lingers on close.

SO_OOBINLINE

Out-of-band data is transmitted in line.

SO_RCVBUF

Receive buffer size.

SO_RCVLOWAT

Receive ``low water mark''.

SO_RCVTIMEO

Receive timeout.

SO_REUSEADDR

Reuse of local addresses is supported.

SO_SNDBUF

Send buffer size.

SO_SNDLOWAT

Send ``low water mark''.

SO_SNDTIMEO

Send timeout.

SO_TYPE

Socket type.

The <sys/socket.h> header shall define the following symbolic constant for use as the maximum backlog queue length which may be specified by the backlog field of the listen() function:

SOMAXCONN

The maximum backlog queue length.

The <sys/socket.h> header shall define the following symbolic constants with distinct values for use as the valid values for the msg_flags field in the msghdr structure, or the flags parameter in recv(), recvfrom(), recvmsg(), send(), sendmsg(), or sendto() calls:

MSG_CTRUNC

Control data truncated.

MSG_DONTROUTE

Send without using routing tables.

MSG_EOR

Terminates a record (if supported by the protocol).

MSG_OOB

Out-of-band data.

MSG_NOSIGNAL

No SIGPIPE generated when an attempt to send is made on a stream-oriented socket that is no longer connected.

MSG_PEEK

Leave received data in queue.

MSG_TRUNC

Normal data truncated.

MSG_WAITALL

Attempt to fill the read buffer.

The <sys/socket.h> header shall define the following symbolic constants with distinct values:

AF_INET

Internet domain sockets for use with IPv4 addresses.

AF_INET6

Internet domain sockets for use with IPv6 addresses.

AF_UNIX

UNIX domain sockets.

AF_UNSPEC

Unspecified.

The value of AF_UNSPEC shall be 0.

The <sys/socket.h> header shall define the following symbolic constants with distinct values:

SHUT_RD

Disables further receive operations.

SHUT_RDWR

Disables further send and receive operations.

SHUT_WR

Disables further send operations.

The <sys/socket.h> header shall define the size_t and ssize_t types as described in <sys/types.h>.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

```
int     accept(int, struct sockaddr *restrict, socklen_t *restrict);
int     bind(int, const struct sockaddr *, socklen_t);
int     connect(int, const struct sockaddr *, socklen_t);
int     getpeername(int, struct sockaddr *restrict, socklen_t *restrict);
int     getsockname(int, struct sockaddr *restrict, socklen_t *restrict);
int     getsockopt(int, int, int, void *restrict, socklen_t *restrict);
int     listen(int, int);
ssize_t recv(int, void *, size_t, int);
ssize_t recvfrom(int, void *restrict, size_t, int,

        struct sockaddr *restrict, socklen_t *restrict);
ssize_t recvmsg(int, struct msghdr *, int);
ssize_t send(int, const void *, size_t, int);
ssize_t sendmsg(int, const struct msghdr *, int);
ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *,

        socklen_t);
int     setsockopt(int, int, int, const void *, socklen_t);
int     shutdown(int, int);
int     sockatmark(int);
int     socket(int, int, int);
int     socketpair(int, int, int, int [2]);
```

Inclusion of <sys/socket.h> may also make visible all symbols from <sys/uio.h>.

The following sections are informative.

## APPLICATION USAGE
To forestall portability problems, it is recommended that applications not use values larger than 231 -1 for the socklen_t type.

The sockaddr_storage structure solves the problem of declaring storage for automatic variables which is both large enough and aligned enough for storing the socket address data structure of any family. For example, code with a file descriptor and without the context of the address family can pass a pointer to a variable of this type, where a pointer to a socket address structure is expected in calls such as getpeername(), and determine the address family by accessing the received content after the call.

The example below illustrates a data structure which aligns on a 64-bit boundary. An implementation-defined field _ss_align following _ss_pad1 is used to force a 64-bit alignment which covers proper alignment good enough for needs of at least sockaddr_in6 (IPv6) and sockaddr_in (IPv4) address data structures. The size of padding field _ss_pad1 depends on the chosen alignment boundary. The size of padding field _ss_pad2 depends on the value of overall size chosen for the total size of the structure. This size and alignment are represented in the above example by implementation-defined (not required) constants _SS_MAXSIZE (chosen value 128) and _SS_ALIGNMENT (with chosen value 8). Constants _SS_PAD1SIZE (derived value 6) and _SS_PAD2SIZE (derived value 112) are also for illustration and not required. The implementation-defined definitions and structure field names above start with an <underscore> to denote implementation private name space. Portable code is not expected to access or reference those fields or constants.

```
/*

 *  Desired design of maximum size and alignment.

 */
#define _SS_MAXSIZE 128

    /* Implementation-defined maximum size. */
#define _SS_ALIGNSIZE (sizeof(int64_t))

    /* Implementation-defined desired alignment. */
```

```
/*

 *  Definitions used for sockaddr_storage structure paddings design.

 */
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(sa_family_t))
#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof(sa_family_t)+ \

                      _SS_PAD1SIZE + _SS_ALIGNSIZE))
struct sockaddr_storage {

    sa_family_t  ss_family;  /* Address family. */
/*

 *  Following fields are implementation-defined.

 */

    char _ss_pad1[_SS_PAD1SIZE];

        /* 6-byte pad; this is to make implementation-defined

           pad up to alignment field that follows explicit in

           the data structure. */

    int64_t _ss_align;  /* Field to force desired structure

                           storage alignment. */

    char _ss_pad2[_SS_PAD2SIZE];

        /* 112-byte pad to achieve desired size,

           _SS_MAXSIZE value minus size of ss_family

           __ss_pad1, __ss_align fields is 112. */
};
```

## RATIONALE
None.

## FUTURE DIRECTIONS
None.

## SEE ALSO
<sys_types.h>, <sys_uio.h>

The System Interfaces volume of POSIX.1‐2017, accept(), bind(), connect(), getpeername(), getsockname(), getsockopt(), listen(), recv(), recvfrom(), recvmsg(), send(), sendmsg(), sendto(), setsockopt(), shutdown(), sockatmark(), socket(), socketpair()

## COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .