文件名称process.c
/** * Manage the process and thread * @author:zhoubaochuan * @date:2011-07-13 */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <signal.h> #include <pthread.h> static void handle_thread(const int sig); static void handle_signal(const int sig); int main(int argc,char *argv[]){ /*FILE *fp; fp = fopen(destination,"w"); fprintf(fp,"pid:\n",getpid()); fclose(fp);*/ /* 守护进程 { { {*/ pid_t pid; pid = fork(); if(pid < 0){ /* Create process is failure */ exit(1); } if(pid > 0){ /* Stop the current process(parent process) */ exit(1); } /* 守护进程 end}}} */ pid_t pid1 = fork(); if(pid1 < 0){ fprintf(stderr, "Error: %s:%d\n", __FILE__, __LINE__); exit(1); } /* Parent process'id is > 0,and child process'id is &