linux - Pthread_create causing segmentation fault (C++, Kubutnu 15) -


i in shock , confusion, honestly. after reading several dozen topics on "pthread_create causing segmentation fault" still have problem. did ordered, , result zero: @ stage of debug, program gives segmentation fault on line creation process.

i not understand anything. grateful help. in advance.

#include <iostream> #include <stdio.h> #include <stdlib.h> #include <signal.h>  #include <unistd.h> #include <pthread.h> #include <interfacemanager.h> using namespace std;  interfacemanager iface;    void* watch_for_interfaces(void*) {     iface.monitoring(); }    int main() {          sigset_t   *set;         sigemptyset(&(*set));         sigaddset(&(*set), sigint);         sigaddset(&(*set), sigterm);          pthread_t th1, th2;         int i=1;         if (pthread_create(&th2, null, watch_for_interfaces, (void*)&i) != 0) {           perror("th2 error\n");           exit(1);         }             printf ("terminating\npress eny key\n");         getchar();          exit(exit_success);          return 0;     } 

the problem not pthread_create signal functions.

    sigset_t   *set;     sigemptyset(&(*set));     sigaddset(&(*set), sigint);     sigaddset(&(*set), sigterm); 

here, using uninitialized variable set , passing signal functions undefined. malloc it's necessary can write as

    sigset_t   set;     sigemptyset(&set);     sigaddset(&set, sigint);     sigaddset(&set, sigterm); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -