Luna/libc/include/unistd.h

105 lines
2.8 KiB
C
Raw Normal View History

/* unistd.h: POSIX constants and functions. */
#ifndef _UNISTD_H
#define _UNISTD_H
#define __need_NULL
#include <stddef.h>
#include <bits/seek.h>
#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
#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);
/* 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);
2023-04-08 12:47:34 +00:00
/* 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);
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, ...);
/* 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-03-12 10:15:45 +00:00
/* Call the operating system kernel for a specific service. */
long syscall(long num, ...);
2023-03-12 10:15:45 +00:00
/* Sleep for X microseconds. */
int usleep(useconds_t us);
2023-03-12 10:15:45 +00:00
/* Sleep for X seconds. */
unsigned long sleep(unsigned long seconds);
2023-03-12 10:15:45 +00:00
/* Close a file descriptor. */
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);
/* 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