unistd.h

    UTILS

    Description:

    Provides functions and data structures related to process operations.

    For example, you can use the functions to create and copy a process, and obtain a process ID.

    Since:

    1.0

    Version:

    1.0

    Function Name

    Description

    (int pipefd[2])

    int 

    Creates an anonymous pipe.

    close (int fd)

    int 

    Closes a file with a specified file descriptor.

    (int oldfd)

    int 

    Copies a specified file descriptor.

    dup2 (int oldfd, int newfd)

    int 

    Copies the descriptor of the target file to a specified descriptor.

    (int fd, off_t offset, int whence)

    off_t 

    Sets the offset of the pointer to the file.

    fsync (int fd)

    int 

    Synchronizes a file associated with a specified file descriptor to the storage device.

    (int fd, void buf, size_t size)

    ssize_t 

    Reads the file contents and saves them in a specified buffer location.

    write (int fd, const void buf, size_t size)

    ssize_t 

    Writes the specified content to the file.

    (int fd, void buf, size_t count, off_t offset)

    ssize_t 

    Reads data whose offset is offset and length is count from fd to the buffer.

    pwrite (int fd, const void buf, size_t count, off_t offset)

    ssize_t 

    Writes data from the buffer to fd whose offset is offset and length is count.

    (const char path)

    int 

    Deletes a specified file.

    unlinkat (int fd, const char path, int flag)

    int 

    (const char path)

    int 

    Deletes a directory.

    truncate (const char path, off_t length)

    int 

    Truncates a file to a specified size based on the file path.

    (int fd, off_t length)

    int 

    Truncates a file to a specified length.

    access (const char path, int mode)

    int 

    Checks whether a file has the corresponding permission.

    (const char path)

    int 

    Switches the current working directory to a specified directory.

    getcwd (char buf, size_t size)

    char  

    Obtains the current working directory.

    (unsigned int seconds)

    unsigned int 

    Arranges a signal to be sent to the current process after the number of seconds specified by seconds.

    sleep (unsigned seconds)

    unsigned 

    Sleeps for a period of time.

    (void)

    int 

    Waits for signal.

    fork (void)

    pid_t 

    Creates a new process that inherits from the user-mode data of its parent process.

    (const char path, char const arg[], char const envp[])

    int 

    Executes a specified user program file in ELF format.

    execv (const char path, char const arg[])

    int 

    Executes a specified user program file in ELF format.

    (const char path, const char arg,…)

    int 

    Executes a specified user program file in ELF format.

    execl (const char path, const char arg,…)

    int 

    Executes a specified user program file in ELF format.

    (const char path, char const arg[])

    int 

    Executes a specified user program file in ELF format.

    execlp (const char path, const char arg,…)

    int 

    Executes a specified user program file in ELF format.

    (int status)

    _Noreturn void 

    Exits the process immediately and closes all opened file descriptors in the process.

    swab (const void from, void to, ssize_t n)

    void 

    Swaps bytes.

    (void)

    pid_t 

    Obtains the process ID.

    getppid (void)

    pid_t 

    Obtains the parent process ID.

    (void)

    pid_t 

    Obtains the ID of the process group of the calling process.

    getpgid (pid_t pid)

    pid_t 

    Obtains the ID of the process group whose process ID is specified by pid.

    (pid_t pid, pid_t pgid)

    int 

    Sets the ID of the process group whose process ID is specified by pid.

    getopt (int argc, char const argv[], const char optstring)

    int 

    (void)

    uid_t 

    Obtains the real user ID (UID) of the calling process.

    geteuid (void)

    uid_t 

    Obtains the effective user ID (UID) of the calling process.

    (void)

    gid_t 

    Obtains the real group ID (GID) of the calling process.

    getegid (void)

    gid_t 

    Obtains the effective group ID (GID) of the calling process.

    (int size, gid_t list[])

    int 

    Obtains a list of supplementary user group IDs specific to the calling process.

    setuid (uid_t uid)

    int 

    Sets the real user ID for the calling process.

    (uid_t euid)

    int 

    Sets the effective user ID of the calling process.

    setgid (gid_t gid)

    int 

    Sets the user group ID of the calling process.

    (gid_t egid)

    int 

    Sets the effective user group ID of the calling process.

    pathconf (const char path, int name)

    long 

    Obtains the configuration value of a file.

    (uid_t ruid, uid_t euid)

    int 

    Sets the real and effective user IDs of the calling process.

    setregid (gid_t rgid, gid_t egid)

    int 

    Sets the real and effective user group IDs of the calling process.

    (void)

    pid_t 

    Sets the process group ID of the calling process.

    usleep (unsigned useconds)

    int 

    Sleeps for several microseconds.

    (unsigned value, unsigned interval)

    unsigned 

    Sets a microsecond-level timer.

    setgroups (size_t size, const gid_t list)

    int 

    Sets the supplementary user group list of the calling process.

    (uid_t ruid, uid_t euid, uid_t suid)

    int 

    Sets the real, effective, and saved user IDs of the calling process.

    setresgid (gid_t rgid, gid_t egid, gid_t sgid)

    int 

    Sets the real, effective, and saved group IDs of the calling process.

    (uid_t ruid, uid_t euid, uid_t suid)

    int 

    Obtains the real, effective, and saved user IDs of the calling process.

    getresgid (gid_t rgid, gid_t egid, gid_t sgid)

    int 

    Obtains the real, effective, and saved user group IDs of the calling process.

    (void)

    char  

    Obtains the name of the current working directory.

    sbrk (intptr_t increment)

    void  

    Adjusts the heap size of a process.

    (void)

    int 

    Obtains the memory page size.

    chown (const char pathname, uid_t owner, gid_t group)

    int