上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: 什么是守护进程q 守护进程是在后台运行不受控端控制的进程,通常情况下守护进程在系统启动时自动运行q 守护进程的名称通常以d结尾,比如sshd、xinetd、crond等创建守护进程步骤q 调用fork(),创建新进程,它会是将来的守护进程q 在父进程中调用exit,保证子进程不是进程组组长q 调用s... 阅读全文
posted @ 2015-04-16 16:52 张仕传 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 1、wait和waitpid出现的原因SIGCHLDq 当子进程退出的时候,内核会向父进程发送SIGCHLD信号,子进程的退出是个异步事件(子进程可以在父进程运行的任何时刻终止)q 子进程退出时,内核将子进程置为僵尸状态,这个进程称为僵尸进程,它只保留最小的一些内核数据结构,以便父进程查询子进程的退... 阅读全文
posted @ 2015-04-16 16:42 张仕传 阅读(973) 评论(0) 推荐(0) 编辑
摘要: 进程终止的5种方式q 正常退出q 从main函数返回q 调用exitq 调用_exitq 异常退出q 调用abort 产生SIGABOUT信号q 由信号终止 ctrl+c SIGINTeg:区别1:清空缓冲区的操作int main(void){ printf("hello itcast"); //r... 阅读全文
posted @ 2015-04-16 16:37 张仕传 阅读(916) 评论(0) 推荐(2) 编辑
摘要: #include#include#include#include #include#include #include #include #include //演示父子进程共享文件描述符//相当于2个fd指向同一块内存空间.//因为2个进程共享了文件指针偏移量,所以都能向文件中有序写数据int mai... 阅读全文
posted @ 2015-04-15 15:16 张仕传 阅读(1135) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include #include#include #include #include #include // 演示 vfork// vfork共享父进程的数据段// vfork函数必须和execle这类函数在一起或者exit// 不建议使用vfork... 阅读全文
posted @ 2015-04-15 15:15 张仕传 阅读(344) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include #include#include int main(void){ printf("sfsdfsfd"); // 这里没有加\n //exit(0); _exit(0); // 打印不出来 return 0;... 阅读全文
posted @ 2015-04-15 15:14 张仕传 阅读(200) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include #include#include /*孤儿进程int main(void){ pid_t pid; pid = fork(); if (-1 == pid) { perro... 阅读全文
posted @ 2015-04-15 15:13 张仕传 阅读(153) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include #includevoid LoopFunc(int);int main(void){ int procNum = 0; int loopNum = 0; int i, j; pid_t pid; ... 阅读全文
posted @ 2015-04-15 15:12 张仕传 阅读(254) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include #include//fork进程//变量的引申 每一个进程有独立的进程地址空间有更深入的理解//写实复制理解// 1. 子进程修改变量时拷贝// 2. 只拷贝页 ----> Linux内核内存管理机制int main(void){... 阅读全文
posted @ 2015-04-15 15:11 张仕传 阅读(527) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include #include//fork进程//一次调用,两个分支返回//Linux内核如何做到的这一点?// 每一个进程在各自的地址空间中返回//为什么fork返回值设计成>0是父进程分支 =0是子进程分支// 父子关系是1:n的关系,... 阅读全文
posted @ 2015-04-15 15:09 张仕传 阅读(386) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 下一页