2023-01-06 19:02:07 +00:00
|
|
|
/* unistd.h: POSIX constants and functions. */
|
|
|
|
|
2023-01-06 12:31:14 +00:00
|
|
|
#ifndef _UNISTD_H
|
|
|
|
#define _UNISTD_H
|
|
|
|
|
2023-01-06 19:02:07 +00:00
|
|
|
#define __need_NULL
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2023-03-12 12:15:24 +00:00
|
|
|
#include <bits/seek.h>
|
2023-01-06 16:35:07 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2023-03-19 18:19:20 +00:00
|
|
|
#define STDIN_FILENO 0
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
#define STDERR_FILENO 2
|
2023-03-18 18:23:18 +00:00
|
|
|
|
2023-05-19 17:59:20 +00:00
|
|
|
#define _POSIX_CHOWN_RESTRICTED 200112L
|
|
|
|
#define _POSIX_SHELL 200112L
|
|
|
|
|
2023-01-06 12:31:14 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2023-03-18 22:58:56 +00:00
|
|
|
/* Create a new process that is a clone of the current one. */
|
|
|
|
pid_t fork(void);
|
2023-03-11 21:19:58 +00:00
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Return the current process' process ID. */
|
2023-03-11 21:19:58 +00:00
|
|
|
pid_t getpid(void);
|
2023-01-06 16:35:07 +00:00
|
|
|
|
2023-03-24 16:39:55 +00:00
|
|
|
/* Return the current process' parent process ID. */
|
|
|
|
pid_t getppid(void);
|
|
|
|
|
2023-04-08 11:50:18 +00:00
|
|
|
/* Return the current process' real user ID. */
|
|
|
|
uid_t getuid(void);
|
|
|
|
|
|
|
|
/* Return the current process' effective user ID. */
|
|
|
|
uid_t geteuid(void);
|
|
|
|
|
|
|
|
/* Return the current process' real group ID. */
|
|
|
|
gid_t getgid(void);
|
|
|
|
|
|
|
|
/* Return the current process' effective group ID. */
|
|
|
|
gid_t getegid(void);
|
|
|
|
|
|
|
|
/* Set the current process' user IDs. */
|
|
|
|
int setuid(uid_t uid);
|
|
|
|
|
|
|
|
/* Set the current process' effective user ID. */
|
|
|
|
int seteuid(uid_t uid);
|
|
|
|
|
|
|
|
/* Set the current process' group IDs. */
|
|
|
|
int setgid(gid_t gid);
|
|
|
|
|
|
|
|
/* Set the current process' effective group ID. */
|
|
|
|
int setegid(gid_t gid);
|
|
|
|
|
2023-04-08 12:47:34 +00:00
|
|
|
/* Change the owner and group of a file. */
|
|
|
|
int chown(const char* path, uid_t uid, gid_t gid);
|
|
|
|
|
2023-05-19 17:59:20 +00:00
|
|
|
/* Change the owner and group of a file descriptor. */
|
|
|
|
int fchown(int fd, uid_t uid, gid_t gid);
|
|
|
|
|
2023-03-18 21:31:16 +00:00
|
|
|
/* Replace the current process with another one. On success, does not return. */
|
|
|
|
int execv(const char* path, char* const* argv);
|
|
|
|
|
2023-03-30 19:28:39 +00:00
|
|
|
/* Replace the current process with another one. On success, does not return. */
|
|
|
|
int execl(const char* path, const char* arg, ...);
|
|
|
|
|
2023-04-25 18:25:51 +00:00
|
|
|
/* Replace the current process with another one. On success, does not return. */
|
|
|
|
int execlp(const char* path, const char* arg, ...);
|
|
|
|
|
2023-04-25 15:42:19 +00:00
|
|
|
/* Replace the current process with another one. On success, does not return. */
|
|
|
|
int execle(const char* path, const char* arg, ...);
|
|
|
|
|
2023-04-07 13:03:38 +00:00
|
|
|
/* Replace the current process with another one. On success, does not return. */
|
|
|
|
int execve(const char* path, char* const* argv, char* const* envp);
|
|
|
|
|
2023-04-07 13:39:10 +00:00
|
|
|
/* Replace the current process with another one. On success, does not return. */
|
|
|
|
int execvp(const char* name, char* const* argv);
|
|
|
|
|
|
|
|
/* Replace the current process with another one. On success, does not return. */
|
|
|
|
int execvpe(const char* name, char* const* argv, char* const* envp);
|
2023-01-06 16:35:07 +00:00
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Call the operating system kernel for a specific service. */
|
2023-01-06 19:02:07 +00:00
|
|
|
long syscall(long num, ...);
|
2023-01-06 12:31:14 +00:00
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Sleep for X microseconds. */
|
2023-01-22 14:00:20 +00:00
|
|
|
int usleep(useconds_t us);
|
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Sleep for X seconds. */
|
2023-01-22 14:00:20 +00:00
|
|
|
unsigned long sleep(unsigned long seconds);
|
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Close a file descriptor. */
|
2023-03-11 16:45:20 +00:00
|
|
|
int close(int fd);
|
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Read bytes from a file descriptor. */
|
2023-03-11 17:02:50 +00:00
|
|
|
ssize_t read(int fd, void* buf, size_t size);
|
|
|
|
|
2023-03-12 10:37:41 +00:00
|
|
|
/* Write bytes to a file descriptor. */
|
|
|
|
ssize_t write(int fd, const void* buf, size_t size);
|
|
|
|
|
2023-03-12 12:15:24 +00:00
|
|
|
/* Modify a file descriptor's offset. */
|
|
|
|
off_t lseek(int fd, off_t offset, int whence);
|
|
|
|
|
2023-03-24 20:33:20 +00:00
|
|
|
/* Duplicate a file descriptor. */
|
|
|
|
int dup(int fd);
|
|
|
|
|
2023-04-25 18:37:30 +00:00
|
|
|
/* Replace a file descriptor with a copy of another one. */
|
|
|
|
int dup2(int oldfd, int newfd);
|
|
|
|
|
2023-04-11 20:15:21 +00:00
|
|
|
/* Change the current working directory. */
|
|
|
|
int chdir(const char* path);
|
|
|
|
|
2023-04-11 20:45:13 +00:00
|
|
|
/* Retrieve the current working directory. */
|
|
|
|
char* getcwd(char* buf, size_t size);
|
|
|
|
|
2023-04-12 16:11:36 +00:00
|
|
|
/* Remove a name from the filesystem. */
|
|
|
|
int unlink(const char* path);
|
|
|
|
|
2023-05-05 16:50:35 +00:00
|
|
|
/* Remove a name or directory from the filesystem. */
|
|
|
|
int unlinkat(int dirfd, const char* path, int flags);
|
|
|
|
|
2023-04-12 16:11:36 +00:00
|
|
|
/* Remove a directory from the filesystem. */
|
|
|
|
int rmdir(const char* path);
|
|
|
|
|
2023-04-24 19:20:44 +00:00
|
|
|
/* Get the current network hostname. */
|
|
|
|
int gethostname(char* buf, size_t len);
|
|
|
|
|
|
|
|
/* Set the current network hostname. */
|
|
|
|
int sethostname(const char* buf, size_t len);
|
|
|
|
|
2023-05-10 20:48:31 +00:00
|
|
|
/* Create a pipe for inter-process communication. */
|
|
|
|
int pipe(int pfds[2]);
|
|
|
|
|
2023-05-20 19:47:20 +00:00
|
|
|
/* Create a symbolic link. */
|
|
|
|
int symlink(const char* target, const char* linkpath);
|
|
|
|
|
|
|
|
/* Create a symbolic link relative to a file descriptor. */
|
|
|
|
int symlinkat(const char* target, int dirfd, const char* linkpath);
|
|
|
|
|
2023-05-23 13:42:38 +00:00
|
|
|
/* Read the contents of a symbolic link. */
|
|
|
|
ssize_t readlink(const char* path, char* buf, size_t max);
|
|
|
|
|
|
|
|
/* Read the contents of a symbolic link relative to a file descriptor. */
|
|
|
|
ssize_t readlinkat(int dirfd, const char* path, char* buf, size_t max);
|
|
|
|
|
2023-01-06 12:31:14 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|