Linux.com

Home Linux Community Forums Programming and Development Software Development GDB singals waiting tasks when debugging my code

GDB singals waiting tasks when debugging my code

Link to this post 11 Sep 11

Hello,
I found out a problem when I run my code on linux on debug mode (it never happens when I run the exe file).
On my code I use few tasks. On the start of running my code I send all of them to wait, using the command: sem_wait.
Example:
while (rc==-1)
{
rc = sem_wait(&m_sem);
}

Eventhough, sometimes my tasks are waking up without any reason.
I did few searches, and I found out that the GDB signals my tasks and it is a known error.
The solution that people offered is the following code:
while (rc==-1)
{
rc = sem_wait(&m_sem);
if (rc==-1 && errno == EINTR)
{
continue;
}
else
{
break;
}
}

I am using Rhapsody 7.5.3 (for writing my code), and on Rhapsody's framework files I have the following code:
while (rc==-1)
{
rc = sem_wait(&m_sem);
#ifdef OM_SEMAPHORE_CAN_BE_INTERRUPTED
if (rc==-1 && errno == EINTR)
{
continue;
}
else
{
#endif
break;
}
}

Like you can see, compile my code with the OM_SEMAPHORE_CAN_BE_INTERRUPTED can solve the problem.
But, this is a lib file for me. Therefore, If I will change that flag for debug, it will be also changed when I execute my (as an exe file).
Do you think it can create another problem for me or is it ok?

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board