Hey,
first i will post my code, then i say what happens when i start the program.
ok i run this and look at the process table:Code:int fork_service(service_t *s){ int pid; pid = fork(); if (pid == -1){ perror("ERRfork_service: "); return -1; } if (pid == 0){ // child int ret; if ((ret = execvp(s->path, s->flags)) == -1){ perror("ERRfork_service: "); //should never get here //need to free allocations? exit(EXIT_FAILURE); } } //parent; return pid; }
#ps -ax
...
9228 pts/5 S+ 0:00 ./a.out
9232 pts/5 Z+ 0:00 [thttpd] <defunct>
9233 ? Ss 0:00 /usr/sbin/thttpd -C /etc/thttpd/thttpd.conf
...
and
#ps -ejH says that the zombie is a child of a.out, and the running thttpd process is a direct child of init.
say if i am right with this:
when thttpd starts it immediately forks a copy of its own, then the "original" thttpd exits, (...and becomes a zombie), and "init" inherits the thttpd child.
now i am out of control of killing the process that i started at some time in the program, which originally was my plan...
is the thttpd behavior like an often used strategy or so?
thanks for any comments,
felix



LinkBack URL
About LinkBacks


