[英]Multithreaded Program Gets Interrupted with “Alarm Clock”
All, my multithreaded program keeps getting interrupted and "Alarm clock" is being written to console. 所有,我的多线程程序不断被打断,并且“闹钟”正在写入控制台。
After some googling, many people mention this is related to "sleep," but none of my threads are calling sleep. 经过一番谷歌搜索后,许多人提到这与“睡眠”有关,但是我的线程都没有调用睡眠。 The current process is 目前的流程是
n
threads and passes function from (1) and proper parameters to each thread Starter函数启动n
线程,并将函数(1)和适当的参数传递给每个线程 pthread_join(cur_thread[i], 0)
入门函数将连接每个创建的线程pthread_join(cur_thread[i], 0)
I've been trying to use strace
and gdb
to figure out whats throwing the signal. 我一直在尝试使用strace
和gdb
找出引发信号的原因。 gdb
just says "No stack" and strace
doesn't stop at all... I'm thinking I'm about to over write the SIGALRM signal handler... gdb
只是说“没有堆栈”,而strace
根本不会停止...我想我将要过度写SIGALRM信号处理程序...
I'm out of ideas, could anyone offer any suggestions? 我没有主意,有人可以提供任何建议吗?
New information : This seems to be related to libcurl. 新信息 :这似乎与libcurl有关。 I use it to get mjpegs from the network. 我用它从网络上获取mjpegs。 If I do not use libcurl, the SIGALRM does not fire. 如果我不使用libcurl,则不会触发SIGALRM。 My libcurl code is as follows: 我的libcurl代码如下:
static void * capture_function(void * cam)
{
MyData * camera = (MyData *)cam;
//Create the curl
camera->m_curl = curl_easy_init();
//Connect to the camera
curl_easy_setopt(camera->m_curl, CURLOPT_URL, camera->m_ip);
//Set up our callback functions
curl_easy_setopt(camera->m_curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
curl_easy_setopt(camera->m_curl, CURLOPT_WRITEDATA, (void *)camera);
curl_easy_perform(camera->m_curl);
camera->m_state = camera->m_state & ~CAPTURING; //Remove the capturing flag;
curl_easy_cleanup(camera->m_curl);
return NULL;
}
This was related to libcurl
. 这与libcurl
有关。 I had to use 我不得不用
setopt(handle, CURLOPT_NOSIGNAL, 1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.