上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页
摘要: 守护进程 ​ 通常,执行命令都要在终端执行。产生的进程也于终端相联系,当shell退出时,和这和终端相关联的进程会收到SIGHUP信号,默认动作是终止进程。守护进程就是一个不依赖终端的进程 进程组 shell启动一个进程,会给该进程创建一个进程组,进程组id就是进程的pid,也可以用setpgrp函 阅读全文
posted @ 2022-01-20 14:26 hellozhangjz 阅读(62) 评论(0) 推荐(0)
摘要: #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <time.h> #define S 阅读全文
posted @ 2022-01-20 13:11 hellozhangjz 阅读(57) 评论(0) 推荐(0)
摘要: 捕捉信号 signal()函数(不建议) #include <signal.h> typedef void(*sighandler_t)(int); sighandler_t signal(int signum, sighandler_t handler); 功能: 注册信号处理函数(不可用于 SI 阅读全文
posted @ 2022-01-19 15:54 hellozhangjz 阅读(67) 评论(0) 推荐(0)
摘要: 信号集 阻塞信号集:sigprocmask()函数 ​ 有的进程想延迟处理一些信号,但又不能忽略,于是就有了阻塞信号的需求。将一些信号值添加到阻塞信号集记录,这些信号发送给进程时进程收不到信号(相当于黑名单),然后将这些信号移除阻塞信号集,进程会立马收到这些信号,进而进行处理。 ​ 信号集类型是si 阅读全文
posted @ 2022-01-19 15:37 hellozhangjz 阅读(55) 评论(0) 推荐(0)
摘要: 定时产生信号:alarm()函数 #include <unistd.h> unsigned int alarm(unsigned int seconds); 功能: 设置定时器(闹钟)。在指定seconds后(自然计时法),内核会给当前进程发送14 SIGALRM信号。进程收到该信号,默认动作终止。 阅读全文
posted @ 2022-01-19 15:19 hellozhangjz 阅读(67) 评论(0) 推荐(0)
摘要: 信号的产生 信号的产生是由内核检测到中断,例如Ctrl C或者代码里有除以0,然后系统内核根据不同的类型发送给进程不同的信号。 查看信号的编号用kill -l。 常规信号: 编号 信号 对应事件 默认动作 1 SIGHUP 用户退出shell时,由该shell启动的所有进程将收到这个信号 终止进程 阅读全文
posted @ 2022-01-19 15:07 hellozhangjz 阅读(139) 评论(0) 推荐(0)
摘要: A,B双方通信,A想向B发送信息,又不想让别人知道,使用非对称加密:若A向B发送信息,A需要知道B的公钥简称B-pub,用B-pub加密信息后 发送给B,B再用自己的私钥B-prv解密出信息。 A想验证B的身份,可以把“123”用B-pub加密后发送给B,若B能用B-prv解密出来并发送给A,那么A 阅读全文
posted @ 2022-01-18 22:42 hellozhangjz 阅读(117) 评论(0) 推荐(0)
摘要: 一个管道文件的通信半双工的,且不能用lseek()函数操作,其他操作与普通文件一样。 1、匿名pipe #include <unistd.h> int pipe(int pipefd[2]); 功能:创建无名管道。 参数: pipefd : 为 int 型数组的首地址,其存放了管道的文件描述符 pi 阅读全文
posted @ 2022-01-18 14:33 hellozhangjz 阅读(31) 评论(0) 推荐(0)
摘要: 进程间控制 一、创建进程:fork()函数 #include <sys/types.h> #include <unistd.h> pid_t fork(void); 功能: 用于从一个已存在的进程中创建一个新进程,新进程称为子进程,原进程称为父进程。 参数: 无 返回值: 成功:子进程中返回 0,父 阅读全文
posted @ 2022-01-18 14:11 hellozhangjz 阅读(51) 评论(0) 推荐(0)
摘要: #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <string.h> const i 阅读全文
posted @ 2022-01-18 11:17 hellozhangjz 阅读(45) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页