摘要: 信号捕捉 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> void capture_sig(int code) { printf("capture s 阅读全文
posted @ 2020-08-24 21:13 x_Aaron 阅读(158) 评论(0) 推荐(0)
摘要: 信号忽略行为 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> int main() { struct sigaction nact, oact; na 阅读全文
posted @ 2020-08-24 21:09 x_Aaron 阅读(193) 评论(0) 推荐(0)
摘要: 设置屏蔽信号集 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> int main() { // 定义 sigset_t nset, oset; // 阅读全文
posted @ 2020-08-24 20:52 x_Aaron 阅读(101) 评论(0) 推荐(0)
摘要: Linux进程间的通信 常见的进程间通信方式: 管道(有名/匿名管道)、消息队列(systemv、posix两个版本)、内存共享映射(MMAP)、网络套接字 信号量、条件变量、互斥锁、文件锁、进程锁、信号等 管道 绝大多数进程间的通信都是基于内核区域 在内核中建立一个缓冲区, 两个进程向缓冲区读/写 阅读全文
posted @ 2020-08-24 20:40 x_Aaron 阅读(358) 评论(0) 推荐(0)
摘要: mmap进程间通信 写端 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcn 阅读全文
posted @ 2020-08-24 11:53 x_Aaron 阅读(165) 评论(0) 推荐(0)
摘要: 有名管道 进程A #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h 阅读全文
posted @ 2020-08-24 09:20 x_Aaron 阅读(125) 评论(0) 推荐(0)
摘要: 使用管道完成简单进程通信 /* 使用匿名管道完成父子进程通信 */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #define MESSAGE "can you hear me?" in 阅读全文
posted @ 2020-08-24 08:53 x_Aaron 阅读(179) 评论(0) 推荐(0)
摘要: Linux进程 进程是程序的动态表现, 是分配资源(内存、时间片)的基本单位 Linux下进程结构:抢亲缘关系(父子进程) PCB控制块: 进程pid、进程状态、进程启动时长等 PCB中记录了操作系统所需的,用于描述进程的当前情况以及控制进程运行的全部信息。 进程创建过程 0~3G:用户空间 3G~ 阅读全文
posted @ 2020-08-23 15:54 x_Aaron 阅读(206) 评论(0) 推荐(0)
摘要: Linux命令 ls # 查看当前目录下的内容 -l # cd 目录名 # 进入目录 touch 文件名 # 创建文件 ps aux # 查看所有进程(任务管理器) which 命令 # 查看命令路径 mkdir 目录名 # 创建目录 size 可执行程序 # 查看程序中各段的大小 代码段——数据段 阅读全文
posted @ 2020-08-23 10:04 x_Aaron 阅读(433) 评论(0) 推荐(0)
摘要: GDB调试器 用于观察程序执行流程、排除程序BUG, 可以在任意位置停顿、修改、观察数据 GUI调试器:有图形界面, 可视化调试工具, 开销较大 GDB调试器:开销小, 需要基本命令, 速度快 1. 在工程编译时加上-g选项 gcc test.c -g -o app 2. 执行gdb命令, 启动调试 阅读全文
posted @ 2020-08-22 14:59 x_Aaron 阅读(180) 评论(0) 推荐(0)