/* unistd.h: POSIX constants and functions. */ #ifndef _UNISTD_H #define _UNISTD_H #define __need_NULL #include #include #include #include #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 #ifdef __cplusplus extern "C" { #endif /* Create a new process that is a clone of the current one. */ pid_t fork(void); /* Return the current process' process ID. */ pid_t getpid(void); /* Return the current process' parent process ID. */ pid_t getppid(void); /* 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); /* Change the mode bits of a file. */ int chmod(const char* path, mode_t mode); /* Change the owner and group of a file. */ int chown(const char* path, uid_t uid, gid_t gid); /* Replace the current process with another one. On success, does not return. */ int execv(const char* path, char* const* argv); /* Replace the current process with another one. On success, does not return. */ int execl(const char* path, const char* arg, ...); /* Replace the current process with another one. On success, does not return. */ int execve(const char* path, char* const* argv, char* const* envp); /* 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); /* Call the operating system kernel for a specific service. */ long syscall(long num, ...); /* Sleep for X microseconds. */ int usleep(useconds_t us); /* Sleep for X seconds. */ unsigned long sleep(unsigned long seconds); /* Close a file descriptor. */ int close(int fd); /* Read bytes from a file descriptor. */ ssize_t read(int fd, void* buf, size_t size); /* Write bytes to a file descriptor. */ ssize_t write(int fd, const void* buf, size_t size); /* Modify a file descriptor's offset. */ off_t lseek(int fd, off_t offset, int whence); /* Duplicate a file descriptor. */ int dup(int fd); #ifdef __cplusplus } #endif #endif