mercredi 29 mars 2017

Signal handler error

When I use my_handler as function there is not error but I can't because I have to use another method there.

If I build code below : error: invalid use of member functi on (did you forget the ‘()’ ?)

This is my first program in C++

void Client::my_handler(int s){
    if (s == SIGINT){
        printf("SIGINT\n");
    // here I have to use stop_thread method 
    }
}


int main (int argc, const char **argv) {
  Client client(argc, argv);
  client.before_start();

  struct sigaction sigIntHandler;

  sigIntHandler.sa_handler = (__sighandler_t) client.my_handler; //error here
  sigemptyset(&sigIntHandler.sa_mask);
  sigIntHandler.sa_flags = 0;
  sigaction(SIGINT, &sigIntHandler, NULL);

  client.run();

  return 0;
}

Aucun commentaire:

Enregistrer un commentaire