|
Kill process handling
Hi all. Im new to linux and having problems killing a task in my app.
im sending
if (kill(_main_thread, SIGINT) ==-1)
{
os::sleep(100);
kill(_main_thread, SIGINT);
}
t = waitpid (_main_thread, NULL, WNOHANG);
and i keep getting the error message
ECHILD 10 /* No child processes */
from waitpid function call. I have check and it is calling the correct pid number of the task.
When i check the function list i see the task listed as a zombie process under the correct pid number.
THe app i am killing is mpg321. i check the source and this is what is done on the SIGINT
RETSIGTYPE handle_signals(int sig)
{
static struct timeval last_signal = { 0, 0 };
struct timeval curr_tv;
gettimeofday(&curr_tv, NULL);
if (sig == SIGINT)
{
DBG_INFO(("SIGINT Got\n"));
// if (((curr_tv.tv_sec - last_signal.tv_sec) * 1000000 + (curr_tv.tv_usec - last_signal.tv_usec)) < 1000000) /* Allow a short delay to kill mpg321 */
{
DBG_INFO(("SIGINT Quit\n"));
quit_now = 1;
}
last_signal.tv_sec = curr_tv.tv_sec;
last_signal.tv_usec = curr_tv.tv_usec;
stop_playing_file = 1;
}
else if (sig == -1) /* initialize */
{
last_signal.tv_sec = curr_tv.tv_sec;
last_signal.tv_usec = curr_tv.tv_usec;
}
}
and this is done on the exit of main
if(playdevice)
ao_close(playdevice);
ao_shutdown();
/*Restoring TTY*/
set_tty_restore();
if (ctty)
fclose(ctty);
return(0);
What signal is ment to be sent so the wait function will remove the program from the task list?
Thanks you your time
Alex
|