posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
unistd.h File Reference

POSIX symbolic constants and miscellaneous functions (<unistd.h>) More...

#include "posix_features.h"
#include <stddef.h>
#include <stdint.h>
#include <zephyr/posix/sys/confstr.h>
#include <zephyr/posix/sys/pathconf.h>
#include <zephyr/posix/sys/sysconf.h>
#include <zephyr/toolchain.h>
Include dependency graph for unistd.h:

Go to the source code of this file.

Macros

#define F_OK   0
 Test whether the file exists.
 
#define R_OK   4
 Test whether the file may be read.
 
#define W_OK   2
 Test whether the file may be written.
 
#define X_OK   1
 Test whether the file may be executed.
 
#define SEEK_CUR   1
 Seek relative to the current file offset.
 
#define SEEK_END   2
 Seek relative to the end of the file.
 
#define SEEK_SET   0
 Seek relative to the start of the file.
 
#define F_LOCK   1
 Lock a region of a file (lockf command).
 
#define F_TEST   3
 Test whether a file region is locked (lockf command).
 
#define F_TLOCK   2
 Lock a region, failing immediately if blocked (lockf command).
 
#define F_ULOCK   0
 Unlock a region (lockf command).
 
#define STDERR_FILENO   2
 File descriptor for standard error.
 
#define STDIN_FILENO   0
 File descriptor for standard input.
 
#define STDOUT_FILENO   1
 File descriptor for standard output.
 
#define _POSIX_VDISABLE   ('\0')
 Value used to disable a special character in a terminal.
 
#define _GID_T_DECLARED
 
#define __gid_t_defined
 
#define _OFF_T_DECLARED
 
#define __off_t_defined
 
#define _PID_T_DECLARED
 
#define __pid_t_defined
 
#define __SIZE_TYPE__   unsigned long
 
#define unsigned   signed /* parasoft-suppress MISRAC2012-RULE_20_4-a MISRAC2012-RULE_20_4-b */
 
#define _SSIZE_T_DECLARED
 
#define __ssize_t_defined
 
#define _UID_T_DECLARED
 
#define __uid_t_defined
 
#define _USECONDS_T_DECLARED
 
#define __useconds_t_defined
 

Typedefs

typedef unsigned short gid_t
 
typedef long off_t
 
typedef int pid_t
 
typedef signed long ssize_t
 
typedef unsigned short uid_t
 
typedef unsigned long useconds_t
 

Functions

int access (const char *path, int amode)
 Determine accessibility of a file.
 
unsigned int alarm (unsigned int seconds)
 Schedule an alarm signal (SIGALRM) after a given number of seconds.
 
int chdir (const char *path)
 Change the current working directory.
 
int chown (const char *path, uid_t owner, gid_t group)
 Change the owner and group of a file.
 
int close (int fildes)
 Close a file descriptor.
 
size_t confstr (int name, char *buf, size_t len)
 Determine the value of a configurable system variable by name string.
 
char * crypt (const char *key, const char *salt)
 Encrypt a password string (XSI extension, not recommended for new code).
 
int dup (int fildes)
 Duplicate an open file descriptor to the lowest available descriptor.
 
int dup2 (int fildes, int fildes2)
 Duplicate an open file descriptor to a specific descriptor number.
 
FUNC_NORETURN void _exit (int status)
 Terminate the calling process without calling atexit() handlers.
 
void encrypt (char block[64], int edflag)
 Encrypt or decrypt a 64-bit block using DES (XSI extension).
 
int execl (const char *path, const char *arg0,...)
 Replace the process image with a new program (argument list form).
 
int execle (const char *path, const char *arg0,...)
 Replace process image with a new program plus environment (argument list form).
 
int execlp (const char *file, const char *arg0,...)
 Replace process image using PATH search (argument list form).
 
int execv (const char *path, char *const argv[])
 Replace process image with a new program (vector form).
 
int execve (const char *path, char *const argv[], char *const envp[])
 Replace process image with a new program plus environment (vector form).
 
int execvp (const char *file, char *const argv[])
 Replace process image using PATH search (vector form).
 
int faccessat (int fd, const char *path, int amode, int flag)
 Determine accessibility of a file relative to a directory descriptor.
 
int fchdir (int fildes)
 Change the current working directory to the directory named by a file descriptor.
 
int fchown (int fildes, uid_t owner, gid_t group)
 Change the owner and group of an open file.
 
int fchownat (int fd, const char *path, uid_t owner, gid_t group, int flag)
 Change owner and group of a file relative to a directory descriptor.
 
int fdatasync (int fildes)
 Synchronise the data of an open file to storage (without metadata).
 
int fexecve (int fd, char *const argv[], char *const envp[])
 Replace process image using an open file descriptor (vector form).
 
pid_t fork (void)
 Create a child process.
 
long fpathconf (int fildes, int name)
 Determine the value of a configurable limit for an open file.
 
int fsync (int fd)
 Synchronise an open file's data and metadata to storage.
 
int ftruncate (int fildes, off_t length)
 Truncate an open file to a specified length.
 
char * getcwd (char *buf, size_t size)
 Get the pathname of the current working directory.
 
gid_t getegid (void)
 Get the effective group ID of the calling process.
 
int getentropy (void *buffer, size_t length)
 Fill a buffer with cryptographically secure random bytes.
 
uid_t geteuid (void)
 Get the effective user ID of the calling process.
 
gid_t getgid (void)
 Get the real group ID of the calling process.
 
int getgroups (int gidsetsize, gid_t grouplist[])
 Get the supplementary group IDs of the calling process.
 
long gethostid (void)
 Get a unique identifier for the host system (XSI extension).
 
int gethostname (char *name, size_t namelen)
 Get the name of the current host.
 
char * getlogin (void)
 Get the login name of the user.
 
int getlogin_r (char *name, size_t namesize)
 Get the login name of the user into a caller-supplied buffer.
 
int getopt (int argc, char *const argv[], const char *optstring)
 Parse command-line options.
 
pid_t getpgid (pid_t pid)
 Get the process group ID of a process.
 
pid_t getpgrp (void)
 Get the process group ID of the calling process.
 
pid_t getpid (void)
 Get the process ID of the calling process.
 
pid_t getppid (void)
 Get the process ID of the parent of the calling process.
 
pid_t getsid (pid_t pid)
 Get the session ID of a process.
 
uid_t getuid (void)
 Get the real user ID of the calling process.
 
int isatty (int fildes)
 Determine whether a file descriptor refers to a terminal.
 
int lchown (const char *path, uid_t owner, gid_t group)
 Change the owner and group of a symbolic link.
 
int link (const char *path1, const char *path2)
 Create a hard link.
 
int linkat (int fd1, const char *path1, int fd2, const char *path2, int flag)
 Create a hard link relative to directory file descriptors.
 
int lockf (int fildes, int function, off_t size)
 Apply, test, or remove an advisory file lock (XSI extension).
 
off_t lseek (int fildes, off_t offset, int whence)
 Reposition the file offset of an open file descriptor.
 
int nice (int incr)
 Change the scheduling priority of the calling process (XSI extension).
 
long pathconf (const char *path, int name)
 Determine the value of a configurable limit for a file path.
 
int pause (void)
 Suspend process execution until a signal is received.
 
int pipe (int fildes[2])
 Create a pipe — a pair of connected file descriptors.
 
ssize_t pread (int fildes, void *buf, size_t nbyte, off_t offset)
 Read from a file at a given offset without changing the file offset.
 
ssize_t pwrite (int fildes, const void *buf, size_t nbyte, off_t offset)
 Write to a file at a given offset without changing the file offset.
 
ssize_t read (int fildes, void *buf, size_t nbyte)
 Read from a file descriptor.
 
ssize_t readlink (const char *restrict path, char *restrict buf, size_t bufsize)
 Read the value of a symbolic link.
 
ssize_t readlinkat (int fd, const char *restrict path, char *restrict buf, size_t bufsize)
 Read the value of a symbolic link relative to a directory descriptor.
 
int rmdir (const char *path)
 Remove an empty directory.
 
int setegid (gid_t gid)
 Set the effective group ID of the calling process.
 
int seteuid (uid_t uid)
 Set the effective user ID of the calling process.
 
int setgid (gid_t gid)
 Set the real group ID of the calling process.
 
int setpgid (pid_t pid, pid_t pgid)
 Set the process group ID for a process.
 
pid_t setpgrp (void)
 Set the process group ID to the process ID of the calling process (obsolescent).
 
int setregid (gid_t rgid, gid_t egid)
 Set the real and effective group IDs (XSI extension).
 
int setreuid (uid_t ruid, uid_t euid)
 Set the real and effective user IDs (XSI extension).
 
pid_t setsid (void)
 Create a new session and set the process group ID.
 
int setuid (uid_t uid)
 Set the real user ID of the calling process.
 
unsigned int sleep (unsigned int seconds)
 Suspend execution for at least the specified number of seconds.
 
void swab (const void *ZRESTRICT src, void *ZRESTRICT dest, ssize_t nbytes)
 Swap bytes in a block of memory (XSI extension).
 
int symlink (const char *path1, const char *path2)
 Create a symbolic link.
 
int symlinkat (const char *path1, int fd, const char *path2)
 Create a symbolic link relative to a directory file descriptor.
 
void sync (void)
 Schedule outstanding writes to all file systems (XSI extension).
 
long sysconf (int opt)
 Get a configurable system variable.
 
pid_t tcgetpgrp (int fildes)
 Get the process group ID of the foreground process group of the terminal.
 
int tcsetpgrp (int fildes, pid_t pgid_id)
 Set the foreground process group ID of a terminal.
 
int truncate (const char *path, off_t length)
 Truncate a file on the filesystem to a specified length.
 
char * ttyname (int fildes)
 Get the name of the terminal associated with a file descriptor.
 
int ttyname_r (int fildes, char *name, size_t namesize)
 Get the name of the terminal into a caller-supplied buffer.
 
int unlink (const char *path)
 Remove a directory entry.
 
int unlinkat (int fd, const char *path, int flag)
 Remove a directory entry relative to a directory file descriptor.
 
int usleep (useconds_t useconds)
 Suspend execution for at least the specified number of microseconds (obsolescent).
 
ssize_t write (int fildes, const void *buf, size_t nbyte)
 Write to a file descriptor.
 

Variables

char * optarg
 Argument for the current option from getopt().
 
int opterr
 Error flag for getopt() (non-zero enables error messages).
 
int optind
 Index of the next element to be processed by getopt().
 
int optopt
 Unrecognised option character from getopt().
 

Detailed Description

POSIX symbolic constants and miscellaneous functions (<unistd.h>)

Provides symbolic constants for file access modes, seek positions, and option groups, together with the full set of POSIX miscellaneous functions (process control, file I/O, user/group IDs, and process environment).

See also
POSIX.1-2017 <unistd.h>

Definition in file unistd.h.

Macro Definition Documentation

◆ __gid_t_defined

#define __gid_t_defined

Definition at line 128 of file unistd.h.

◆ __off_t_defined

#define __off_t_defined

Definition at line 134 of file unistd.h.

◆ __pid_t_defined

#define __pid_t_defined

Definition at line 141 of file unistd.h.

◆ __SIZE_TYPE__

#define __SIZE_TYPE__   unsigned long

Definition at line 148 of file unistd.h.

◆ __ssize_t_defined

#define __ssize_t_defined

Definition at line 154 of file unistd.h.

◆ __uid_t_defined

#define __uid_t_defined

Definition at line 160 of file unistd.h.

◆ __useconds_t_defined

#define __useconds_t_defined

Definition at line 167 of file unistd.h.

◆ _GID_T_DECLARED

#define _GID_T_DECLARED

Definition at line 127 of file unistd.h.

◆ _OFF_T_DECLARED

#define _OFF_T_DECLARED

Definition at line 133 of file unistd.h.

◆ _PID_T_DECLARED

#define _PID_T_DECLARED

Definition at line 140 of file unistd.h.

◆ _SSIZE_T_DECLARED

#define _SSIZE_T_DECLARED

Definition at line 153 of file unistd.h.

◆ _UID_T_DECLARED

#define _UID_T_DECLARED

Definition at line 159 of file unistd.h.

◆ _USECONDS_T_DECLARED

#define _USECONDS_T_DECLARED

Definition at line 166 of file unistd.h.

◆ unsigned

#define unsigned   signed /* parasoft-suppress MISRAC2012-RULE_20_4-a MISRAC2012-RULE_20_4-b */

Definition at line 150 of file unistd.h.

Typedef Documentation

◆ gid_t

typedef unsigned short gid_t

Definition at line 126 of file unistd.h.

◆ off_t

typedef long off_t

Definition at line 132 of file unistd.h.

◆ pid_t

typedef int pid_t

Definition at line 139 of file unistd.h.

◆ ssize_t

typedef signed long ssize_t

Definition at line 151 of file unistd.h.

◆ uid_t

typedef unsigned short uid_t

Definition at line 158 of file unistd.h.

◆ useconds_t

typedef unsigned long useconds_t

Definition at line 165 of file unistd.h.