Process termination, process waiting and fork(), wait(), waitpid()

Article directory 1. Process termination (1) Situation of process termination (2) How to terminate the process 2. Process waiting (1) Concept (2) Necessity (3) wait()–system call (4) waitpid()–system call (5) Get child process status 3. fork() function 1. Process termination (1) Process termination situation The code is run and the result is correct The code […]

Process control wait and waitpid functions

When a process terminates normally or abnormally, the kernel sends the SIGCHLD signal to its parent process. Because child process termination is an asynchronous event (this can occur at any time while the parent process is running), this signal is also an asynchronous notification sent by the kernel to the parent process. The parent process […]

C- wait() & waitpid() & status variable & errno

Basic concepts wait() and waitpid() are system calls used on UNIX and Linux systems to make a parent process wait for its child process to terminate. They enable the parent process to collect the child’s exit status when the child process terminates. These two calls also help prevent the creation of zombie processes. 1. wait() […]

[Linux process] process control (middle) {process waiting: the necessity of waiting, the method of process waiting wait, waitpid, exit status status, waitpid non-blocking wait}

3. Process waiting 3.1 Process waiting necessity As mentioned before, if the child process exits, if the parent process is ignored, it may cause the problem of a “zombie process” and cause a memory leak. In addition, once a process becomes a zombie, it is invulnerable, and the “kill without blinking” kill -9 can do […]

Linux system programming – process – process exit, orphan process, zombie process, wait and waitpid functions

Directory process exit exit normally Abnormal exit Zombie and orphan processes Introduction to both Problems and their hazards wait and waitpid functions Introduction to functions Function header files, parameters and return values The difference between wait function and waitpid function Wait function actual combat Orphan process code implementation Programming to implement zombie process Process exit […]

The wait/waitpid function waits for the state of the child process to change

【Process Communication and Concurrency】The topic is being continuously updated. The creation principles and applications of processes, threads, IPC, thread pools, etc.? Welcome to subscribe to this topic to get more detailed information This series of columns – Concurrency and process communication Welcome everyone LikeCommentFavorite Personal Homepage – Go Bar Tingqu_0’s Blog I hope this article […]

Linux system programming 1. fork function getpid function parent-child process sharing but not sharing 2. execl change shell – background process prints to file 3. orphan process zombie process 4. wait and waitpid recycle child process

1. fork function #include <stdio.h> #include <unistd.h> #include <errno.h> #include <stdlib.h> int main(int argc, char * argv[]) { printf(“before fork1\\ “); printf(“before fork2\\ “); printf(“before fork3\\ “); printf(“before fork4\\ “); printf(“before fork5\\ “); printf(“before fork6\\ “); pid_t pid1; pid1 = fork(); if (pid1 == -1) { perror(“fork error”); exit(1); } else if (pid1 == 0) […]

linux_ recycle child process (what is orphan process, zombie process, wait function, waitpid function)

Continued from the previous article: linux_exec function family-execl function-execlp function-execle function-execv function-execvp function-execve function Today I would like to share with you a few interesting knowledge points, One is an orphan process, the other is a zombie process, hhh, isn’t it interesting, let’s take a look at how to recycle child processes, and start serving: […]