用户空间与内核空间
最后更新于
// 常见的系统调用
int fd = open("file.txt", O_RDONLY); // 打开文件
ssize_t bytes = read(fd, buffer, size); // 读取数据
int result = write(fd, buffer, size); // 写入数据
int status = close(fd); // 关闭文件// 文件操作
int open(const char *pathname, int flags);
ssize_t read(int fd, void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count);
// 进程控制
pid_t fork(void);
void exit(int status);
pid_t wait(int *status);
// 网络通信
int socket(int domain, int type, int protocol);
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);# 查看系统信息
$ cat /proc/cpuinfo
$ cat /proc/meminfo
$ cat /proc/version
# 查看进程信息
$ cat /proc/<pid>/status
$ cat /proc/<pid>/maps