I am trying to ptrace a sshd daemon. The following simple program is attached to the daemon. Whenever a ssh client connection is closed, the new generated sshd process turns into zombie process. Could you give me any comments? Thanks in advance.
int main(int argc, char *argv[])
{
pid_t traced_process;
int status = 0;
if(argc != 2){
printf("Usage: %s <pid to be traced>\n", argv[0]);
exit(1);
}
traced_process = atoi(argv[1]);
ptrace(PTRACE_ATTACH, traced_process, NULL, NULL);
while(1){
wait(&status);
if(WIFEXITED(status)){
break;
}
ptrace(PTRACE_SYSCALL, traced_process, NULL, NULL);
} // end of while
return 0;
}