thanks for the info, yea i removed pthread_exit, i need to use (void *)devName.c_str() as the thread requires a device name to call the driver.Or the compiler would complain
Originally Posted by MadCow108
As for the segmentation faults, it was not the threading problem but rather my codes went haywire in a thread.I confirmed this with a simple cout in the thread.
Strange thing is that it worked okay when i fork() it.
I post the code for everyone to see(scrutinize) Anyone good with ioctl calls? I am still new to it.
//changing of channels
void* changeChannel(void* args)
char* devName = (char*) args;
int channel = 0;
int fd = sock_open();
struct iw_freq freq;
struct iwreq* reqDev;
reqDev->u.freq = freq;//segfault seeems to come from here?
strncpy(reqDev->ifr_name, devName, IFNAMSIZ);
ioctl(fd, SIOCSIWFREQ , reqDev);
//here create a thread to changing channels, and start capturing packets. devName is a std::string that contains a device name
int t = pthread_create(&chgchannel,NULL,&changeChannel, (void *)devName.c_str() );
std::cout << "fail" << std::endl;
std::cout << "got:"+client << std::endl;
std::cout << "finished" << std::endl;