Wifexited/wexitstatus/wifsignaled if the exit status value (* Note program termination: :) of the childprocess is zero, then the status value reported by 'waitpid 'or 'wait' is also zero. you can test for other kinds of information encoded inthe
The function prototype for wait () is: #include #include pid_t wait (int *status)
Once the process has called wait, it blocks itself immediately, and the wait automatically analyzes whether a subprocess of the current process has exited. If you
When a process is normal or abnormally terminated, the kernel sends a SIGCHLD signal like its parent process because the child process is an asynchronous event, so this signal is also the asynchronous notification that the kernel sends to that
System Functions
Function: Call fork to generate a sub-process, which is called by the sub-process;/bin/sh-C command to execute the command represented by the command parameter, blocking the current process until the command is killed
The execution
Before studying the wait and WAITPID functions, I was puzzled by the use of macro wifexited to check the resulting process termination state: Typically we exit by calling the exit or _exit function in the program. So the terminating state of the
(Switch) Linux Process Control-Wait ()
# Include /* define the pid_t type */# Include Pid_t wait (int * Status)
Once a process calls wait, it immediately blocks itself. Wait automatically analyzes whether a sub-process of the current
1.8 wait
1.8.1 Overview
The wait function is prototype:
# Include /* define the pid_t type */# Include Pid_t wait (int * Status)
Once a process calls wait, it immediately blocks itself. Wait automatically analyzes
Botnets
In the previous article, we have understood the concepts of parent and child processes, and have mastered the usage of System Call exit, but few people may realize that, after a process calls exit, it does not disappear immediately, but
INT system (const char * character string){Pid_t PID;Int status;
If (else string = NULL ){Return (1 );}
If (pid = fork () Status =-1;}Else if (pid = 0 ){Execl ("/bin/sh", "sh", "-c", character string, (char *) 0 );-Exit (127); // The sub-process
#include /*provides a definition of type pid_t*/#includepid_t Wait (int*status) Once the process has called wait, it blocks itself immediately, and the wait automatically parses if a child process of the current process has exited, and if it finds
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.