摘要:
fork和vfork都会创建子进程,它们有什么区别呢?一、fork:子进程拷贝父进程的数据段 vfork:子进程与父进程共享数据段二、fork:父、子进程的执行次序不确定 vfork:子进程先运行,父进程后运行#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <signal.h>int main (int argc, char *argv[]){ int number = 0; pid_t pid; pid = vfork(); number++; printf(&q 阅读全文
posted @ 2013-05-07 20:04
robotke1
阅读(270)
评论(0)
推荐(0)
摘要:
(1)用wait和waitpid函数清理僵尸进程,父进程可以阻塞等待子进程结束(2)父进程在信号处理函数中wait()清理子进程其实,子进程在终止时会给父进程发SIGCHLD信号,该信号的默认处理动作是忽略,父进程可以自定义SIGCHLD信号的处理函数,这样父进程只需专心处理自己的工作,不必关心子进程了,子进程终止时会通知父进程,父进程在信号处理函数中调用wait清理子进程即可。例子1:#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <signal.h>void s 阅读全文
posted @ 2013-05-07 17:40
robotke1
阅读(395)
评论(0)
推荐(0)
摘要:
(转载)http://blog.chinaunix.net/uid-21206300-id-3018578.html(1)产生僵尸进程#include <stdio.h>#include <stdlib.h>#include <unistd.h>int main (int argc, char *argv[]){ pid_t pid = fork(); if (pid == 0) { int i = 0; while (i++ < 6) { printf("child running...\n"); sleep(... 阅读全文
posted @ 2013-05-07 16:45
robotke1
阅读(582)
评论(1)
推荐(0)
摘要:
(转载)http://www.cnblogs.com/cornsea/archive/2010/06/08/1754369.html例子1:#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <signal.h>#include <sys/prctl.h>void my_system(void){ pid_t pid; pid = fork(); if (pid == 0) { //prctl(PR_SET_PDEATHSIG, SIGHUP); while 阅读全文
posted @ 2013-05-07 15:56
robotke1
阅读(2761)
评论(0)
推荐(0)
摘要:
(转载)http://blog.csdn.net/caianye/article/details/6526150linux下: ctrl-c 发送 SIGINT 信号给前台进程组中的所有进程。常用于终止正在运行的程序。 ctrl-z 发送 SIGTSTP 信号给前台进程组中的所有进程,常用于挂起一个进程。 ctrl-d 不是发送信号,而是表示一个特殊的二进制值,表示 EOF。 ctrl-/ 发送 SIGQUIT 信号给前台进程组中的所有进程,终止前台进程并生成 core 文件。Key Function Ctrl-c Kill foreground process Ctrl-z Suspend 阅读全文
posted @ 2013-05-07 13:32
robotke1
阅读(249)
评论(0)
推荐(0)
摘要:
(转载)http://www.cnblogs.com/duzouzhe/archive/2009/06/19/1506699.html(一)Linux网络编程--网络知识介绍Linux网络编程--网络知识介绍客户端和服务端 网络程序和普通的程序有一个最大的区别是网络程序是由两个部分组成的--客户端和服务器端. 客户端 在网络程序中,如果一个程序主动和外面的程序通信,那么我们把这个程序称为客户端程序。 比如我们使用ftp程序从另外一 个地方获取文件的时候,是我们的ftp程序主动同外面进行通信(获取文件), 所以这个地方我们的ftp程序就是客户端程序。 服务端 和客户端相对应的程序即为服务端程序. 阅读全文
posted @ 2013-05-07 13:31
robotke1
阅读(410)
评论(0)
推荐(0)
摘要:
(转载)http://www.cnblogs.com/zeroone/archive/2010/05/05/1727659.htmlDAYOFWEEK(date) 返回日期date是星期几(1=星期天,2=星期一,……7=星期六,ODBC标准)mysql> select DAYOFWEEK('1998-02-03'); -> 3 DAYOFMONTH(date) 返回date是一月中的第几日(在1到31范围内) mysql> select DAYOFMONTH('1998-02-03'); -> 3 DAYOFYEAR(date) 返回d 阅读全文
posted @ 2013-05-07 13:30
robotke1
阅读(156)
评论(0)
推荐(0)

浙公网安备 33010602011771号