Error in sem_wait..

Sysprogs forums Forums VisualGDB Error in sem_wait..

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #623
    Anonymous
    Participant

    In my Linux project I am using sem_wait which is waiting for sem_post operation to proceed.When I was debugging using VisualGDB, it has given me “interrupted system call” error in sem_wait. Above written code is running fine on Linux machine without debugging.

    Kindly help.

    #2581
    ket
    Participant

    Hi,

    When VisualGDB sets a breakpoint while your program is running, it tells GDB to stop the program, sets the breakpoint and resumes it (GDB cannot set breakpoints asynchronously).

    GDB stops the program by sending a SIGINT to it and handling it. As a side effect, any pending semaphore waits are ended with the EINTR code. As a workaround you can simply make a wrapper for sem_wait() that will check whether the return code is -1 and errno is EINTR and retry the call to sem_wait() in that case.

    #2583
    Anonymous
    Participant

    Hi,

    Even If I am not putting any breakpoints than I also i am getting mentioned error “interrupted system call”.

    Note : My main thread is waiing on sem_wait() and another thread will give signal to main thread for go ahead.

    #2582
    ket
    Participant

    Hi,

    Breaking for breakpoints, any kind of pausing the execution or even internal thread creation and destruction will cause the semaphore to return.
    Read more about the good style of programming for gdb here: http://sourceware.org/gdb/onlinedocs/gdb/Interrupted-System-Calls.html

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.