I am executing a file as a daemon process. How can I stop the daemon?
int main(int argc, char **argv)
{
if ( argc != 5 )
{
printf ("Usage: %s <server> <nick> <channel> <logging>\n", argv[0]);
return 1;
}
char *startPath = malloc(sizeof(char) *100);
strcpy(startPath,"/home/.../start");
int child_pnr;
if(daemonisieren() != 0)
{
printf("damonization not possible");
exit(0);
}
printf("I am a damon \n");
if((child_pnr = fork())==0)
{
execve(startPath,argv);
}
else if (child_pnr > 0)
{
printf("I am parent and have a child \n");
wait(child_pnr);
}
printf("gone....\n");
free(startPath);
}
I presume I can kill it just like kill(childnr) but as the parent process waits for the child to finish execution which he may never do I have to have a program which knows the childnr and kills it. How can I do that?