zombie-process

Fork, execlp and kill. Zombie process

ぃ、小莉子 提交于 2021-02-20 04:13:06
问题 I have a c program that executes another process (bash script) with fork and execlp. When I want to kill this process it moves to a zombiee state. Why is this?? Create a process: switch (PID_BackUp= fork()) { case -1: perror("fork"); printf("An error has occurred launching backup.sh script!\n"); break; case 0: execlp("/usr/local/bin/backup.sh", "/usr/local/bin/backup.sh", NULL, NULL, NULL); break; default: printf("backup.sh script launched correctly! PID: %d\n", PID_BackUp); break; } Kill a

Zombie process and fork

天大地大妈咪最大 提交于 2021-01-28 04:47:45
问题 i have a code like this... c = fork(); if(c==0) { close(fd[READ]); if (dup2(fd[WRITE],STDOUT_FILENO) != -1) execlp("ssh", "ssh", host, "ls" , NULL); _exit(1); } close(fd[WRITE]); fd[READ] and fd[WRITE] are pipe file descriptors. when i run it continuously, there are a lot of zombie processes when i use ps ax. How to rectify this? Is this because i am not using the parent to wait for the exit status of the child process... 回答1: If you have no intention to wait for your child processes, set the

Why zombie processes exist?

有些话、适合烂在心里 提交于 2020-01-20 22:05:27
问题 Wikipedia says "A child process that terminates but is never waited on by its parent becomes a zombie process." I run this program: #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main() { pid_t pid, ppid; printf("Hello World1\n"); pid=fork(); if(pid==0) { exit(0); } else { while(1) { printf("I am the parent\n"); printf("The PID of parent is %d\n",getpid()); printf("The PID of parent of parent is %d\n",getppid()); sleep(2); } } } This creates a zombie process, but I can't

What happens after the parent of zombie process terminates?

 ̄綄美尐妖づ 提交于 2020-01-03 13:35:31
问题 I'm just curious, what happens to zombie process, if it's parent doesn't care to wait for it. Suppose, we've a parent and a child. Child terminates before parent does. From APUE: The kernel keeps a small amount of information for every terminating process...Minimally this information consists of the process ID, the termination status of the process.... Parent is required to fetch this information using waitpid() . But if, parent exits without waiting for child, what happens: Does the kernel

can't create zombie process in linux

别来无恙 提交于 2020-01-02 08:09:31
问题 Well I have weird problem. I can't create a zombie process in my project, but I can do this in other file. There's simple instructions: int main() { if(fork()==0) printf("Some instructions\n"); else { sleep(10); wait(0); } return 0; } That simple code create a zombie process for 10 seconds. I'm checking and it actually exists. But if I copy this code to my program (my own shell), everything executing like before BUT zombie process doesn't exist at all. I don't know what's the difference. It's