The following code starts a lenghty nmap process and then the main program tries to kill it. I am running it from shell and also have GTOP running in another window just to see if all is successfull.
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<unistd.h> #include<errno.h> #include <sys/wait.h> int main() { int ret,childpid=0; ret = fork(); if (ret == 0) { printf("Here A %d.. \n", ret); char *params[5] = {"nmap","-sS","-A","192.168.0.1/24",0}; //cmd params filled childpid = execv( "/usr/bin/nmap" , params); //parameters for cmd printf("\n child exiting (%d) (%d).. \n", childpid,errno); //on successful execution of cmd, this exit never appears } else { childpid=ret; printf("parent exiting\n"); if (childpid!=0) { printf("child %d about to be killed wait 15 so that htop has time to see it\n",childpid); sleep(15); kill(childpid, SIGTERM); sleep(2); kill(childpid, SIGKILL); printf("killed wait 15 HTOP should have time to update\n"); sleep(15); } } return 1; } HTOP see nmap starting but when I kill the process it still shows in the HTOP display. When my main program exit HTOP removes nmap from list of processes. Am I doing something wrong or misinterpreting HTOP?