On Mon, 28 Apr 2003 12:54:27 -0700
dries
Hello List readers,
I've got a problem, i need to kill a program i run by doing a fork and a exec. When i kill the program i do a 'kill(pid,SIGKILL);' then to prevent a zombie i waitpid for the return value : 'waitpid(pid,&status,WUNTRACED);' this should prevent a zombie from forming. However, on slow hardware (it seems timing related), a zombie still appears.
Here are some other details of the problem :
OS : Suse 7.3
Actual kill code :
/* * Make very sure it has ended and get return value */ kill(prog->pid,SIGKILL); waitpid(prog->pid,&status,WUNTRACED); // | WNOHANG);
It happens on slow hardware, it will probably happen on fast hardware too only the change of it happening is muuuucccchh smaller.
Do i do something wrong with the kill or the waitpid ?? I generally use wait(2) rather than waitpid, although waitpid(2) should be working. Did you check the return value from waitpid? It should return either the pid of the process killed or -1. Another way to handle this is to use a SIGCHILD signal handler. -- Jerry Feldman
Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9