在我的应用程序中,main函数调用了一个funciton - f2,它产生了几个线程,应用程序运行得很好。现在,我正尝试在f2之前添加一个新函数f1,以生成一个新线程。这个新线程在屏幕上打印一些东西,并在while循环中进入睡眠状态。我得到了一次打印,一段时间后,应用程序终止。在从GDB调试时,我收到了以下消息:
(gdb) Program received signal SIG34, Real-time event 34.Quit
(gdb) bt
#0 0x0fa97cc8 in __nanosleep_nocancel ()
from /export/home/disk4/omsn/401.03022010/montavista/pro/devkit/ppc/82xx/target/lib/tls/libc.so.6
#1 0x0fa97a50 in __sleep (seconds=0) at sleep.c:137
#2 0x10007098 in f2 (arg=0x204) at main.c:152
#3 0x0fd2197c in start_thread (arg=0x204) at pthread_create.c:256
#4 0x0fac853c in clone ()
at ../sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S:100 warning: Previous frame inner to this frame (corrupt stack?)
代码片段:
main(){
f1(); /*New function added to spawn a new task*/
f2(); /*Existing function spawns several tasks*/
}
有人能告诉我什么是"signal SIG34,Real-time event 34“吗?是什么导致了同样的情况?
以下是f1功能的详细信息:
int f1(){
pthread_t thread_id;
pthread_attr_t attr;
size_t stack_size;
int ret=0;
pthread_attr_init(&attr);
/*Initialize the stack size*/
pthread_attr_getstacksize (&attr, &stack_size);
printf("Default Stack Size = %d\n", stack_size);
stack_size = 2000;
pthread_attr_setstacksize (&attr, stack_size);
/*Initialize detach state*/
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
printf("Going to spawn thread\n");
ret = pthread_create(&thread_id, &attr, task_func, NULL);
if (ret){
printf("ERROR; return code from pthread_create() is %d\n", ret);
return ret;
}else{
printf("thread successfully spawned, thread id - %d\n", thread_id);
}
pthread_attr_destroy(&attr);
return ret;
}
void* task_func(void* arg){
printf ("Inside %s going for long sleep\n",__FUNCTION__);
sleep(100);
while(1){
printf ("Inside %s\n",__FUNCTION__);
sleep(5);
}
}
发布于 2019-05-25 06:13:29
要解决此问题,请创建包含以下内容的.gdbinit
文件:
handle SIG34 nostop noprint pass noignore
发布于 2014-12-03 22:34:18
Linux支持POSIX.1b实时扩展中最初定义的实时信号(现在包含在POSIX.1-2001中)。支持的实时信号范围由宏SIGRTMIN
和SIGRTMAX
定义。你得到了34号信号的软件中断,这是SIGTEMI+0
。在终端中键入以下命令
$ kill -l
您将获得信号列表。您将在此链接上获得有关此信号的更多信息。http://www.freedesktop.org/software/systemd/man/systemd.html我希望这些信息能帮助你找到SIGNAL34背后的原因。因为你还没有更新这里的全部代码,所以很难说为什么你会得到这个signal34。
https://stackoverflow.com/questions/6735791
复制相似问题