摘要: https://blog.csdn.net/jyy305/article/details/73012706 select的优缺点 优点: (1)select的可移植性好,在某些unix下不支持poll. (2)select对超时值提供了很好的精度,精确到微秒,而poll式毫秒。 缺点: (1)单个进 阅读全文
posted @ 2021-10-07 22:46 feiwatson 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 为了阻止一个特定用户登录系统,除使用/dev/null外,还有其他替代方法。 将/bin/false用作登陆shell. 或者 将/bin/true用作登陆shell. 某些系统提供nologin命令。 阅读全文
posted @ 2021-10-06 21:17 feiwatson 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 格式化输出是由5个printf 函数来处理的 #include <stdio.h> int printf(const char *restrict format, ...); int fprintf(FILE *restrict fp, const char *restrict format, .. 阅读全文
posted @ 2021-10-06 19:45 feiwatson 阅读(55) 评论(0) 推荐(0) 编辑
摘要: 示例代码 #include "apue.h" #include <dirent.h> #include <limits.h> #include <time.h> /* function type that is called for each filename */ typedef int Myfu 阅读全文
posted @ 2021-10-05 22:13 feiwatson 阅读(60) 评论(0) 推荐(0) 编辑
摘要: Muduo is a multithreaded C++ network library based on the reactor pattern. https://github.com/chenshuo/muduo https://github.com/chenshuo/muduo-tutoria 阅读全文
posted @ 2021-10-05 13:49 feiwatson 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 执行流程: 1、创建监听 socket,并绑定、监听; 2、调用 epoll_create() , 创建 epollfd 代理; 3、将想要监听的 listenfd,通过 epoll_ctl() , 挂载到 epollfd 上,让 epollfd 代理监听; 4、在一个 while 循环中,调用 e 阅读全文
posted @ 2021-10-05 13:42 feiwatson 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 在unix系统中, 通常write只是将数据排入队列,而实际的写磁盘操作则可能在之后的某个时刻。而数据库系统则需要使用O_SYNC,write直至数据写到磁盘上再返回。这样,当它从write返回时就知道数据已经确实写到磁盘 函数dup 和 dup2 dup 和dup2都可以用来复制一个现有的文件描述 阅读全文
posted @ 2021-10-05 11:05 feiwatson 阅读(27) 评论(0) 推荐(0) 编辑
摘要: ISO C, POSIX, ISO C是C标准;POSIX是可移植操作系统接口标准 ISO C的实现是C standard lib;POSIX对应的实现是C POSIX lib;C POSIX lib是C standard lib的超集; 阅读全文
posted @ 2021-10-03 21:53 feiwatson 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 有三个主要用于进程控制的函数fork,exec, waitpid. exec函数有7中变体。 通过这些进程控制函数,我们即可完成对进程创建、执行和终止等基本操作。进程的控制可以划分为三部曲, • 第一部:fork 创建新进程。 • 第二部:exec 执行新程序。 • 第三部:exit 和 wait 阅读全文
posted @ 2021-10-03 14:25 feiwatson 阅读(55) 评论(0) 推荐(0) 编辑
摘要: 不带缓冲的I/O 函数open, read, write, lseek,close. 这些函数都使用文件描述符。 系统调用 代码实现: 从标准输入读,并写入标准输出 #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include 阅读全文
posted @ 2021-10-02 10:59 feiwatson 阅读(74) 评论(0) 推荐(0) 编辑