Re: Kill gthreads



Thanks for your answer, but I cant use a fork() method
since I have to be able to port the client to windows.

Is there a way to find out what pid a g_thread have
and send a killsignal?

/Johan

Tristan Van Berkom <vantr touchtunes com> wrote:


      If its really just one library call or at least
one library call _Doesnt_ return.... 
(Not very g)libbish code follows ...)

static int thread_id;

void sigchld_handler(int signum) {
      waitpid(thread_id, &status, NULL);      
}


void main() {
/*...*/

      backup_handler = signal(SIGCHLD, sigchld_handler);

      if ((thread_id = fork()) == 0) {
       /*     call that might not return */
          exit();
      } else if (thread_id > 0) {
              g_timeout_add(/*you get the picture ? 
                              in here you can do 
                              "kill(thread_id, SIGTERM);" */);
      }
}


Of course if it was your code that just wont return
I'm sure you could find something alot more elegant.


      -Tristan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]