#include <stdio.h>#include<stdlib.h>#include<string.h>#include<unistd.h>#include<errno.h>#include<signal.h>/*Orphan process int main (void) {pid_t pid; PID = fork (); if ( -1 = = pid) {perror ("fork err"); return 0; } if (pid > 0) {; } if (0 = = pid) {sleep (199); } return 0;}*///Zombie Process//Avoid the method: Create a child process can not pipe process, let the Linux kernel to pipe//Signals: Handling events asynchronously is a mechanism.//The implication is that our program can support asynchronous invocation of signal processing functions while sequentially executing.//stand on the Linux kernel's point of view.intMainvoid) {pid_t pid; //Ignore child process dead signal by signal registration functionsignal (SIGCHLD, sig_ign); PID=Fork (); if(-1==pid) {Perror ("Fork Err"); return 0; } if(PID >0) {Sleep ( -); } if(0==pid) { ; } return 0;}
Copy to Google TranslateTranslation Results
[Learning notes] orphan process zombie process