开发者

sigprocmask resulting in main process getting stuck

开发者 https://www.devze.com 2023-03-30 14:51 出处:网络
I have multi threaded code which used sigprocmask fn. Its known that use of this call is unspecified in Multi threaded program开发者_如何学Python which I understand and i will remove this call. Howeve

I have multi threaded code which used sigprocmask fn. Its known that use of this call is unspecified in Multi threaded program开发者_如何学Python which I understand and i will remove this call. However, the issue that I am facing is that my main thread is stuck if this function is called. I want to understand why this happens. If call to this function is commented out, then main thread executes fine.

In my main program during Init, few thread pools are created. After that I call TestFunction function from which InitModule fn is called. In InitModule, sigprocmask is called and then other initialization is done. The function then returns to TestFunction. This is where it gets stuck.

The usage is as follows

InitModule()
{
   sigset_t x;
   sigemptyset (&x);
   sigprocmask(SIG_SETMASK, &x, NULL)

   // Config read, DS Init, etc ....

}

TestFunction ()
{

  //  Code

  InitModule();
  malloc(); 
  printf("malloc done"); // --> This line is printed
  DoSomethingElse();

  printf("DoSomethingElse done");// --> Never reaches this point. 


  // .... Remaining code.....

}

If I remove sigprocmask() call from InitModule, then I get "DoSomethingElse done" print. How does usage of sigprocmask result in thread getting stuck?

Note that rest of the code in InitModule after call to this fn is always executed. Only when i return to the calling function, thats where it gets stuck.


Some Linux threading libraries implementations use threads internally to communicate between threads for implementing othread_* functions. You are trying to set an empty signal mask. Try leaving there the first 3 real time signals.

0

精彩评论

暂无评论...
验证码 换一张
取 消