[LTP] openposix: timers/twoevtimers: Wait for both timer signals

Li Wang li.wang@linux.dev
Sun Oct 11 03:07:37 CEST 2026


> > > On Fri, 9 Oct 2026, Jan Stancek via ltp wrote:
> > > > openposix: timers/twoevtimers: Wait for both timer signals
> > >
> > > > +   PTS_WRITE_MSG("Caught abort signal\n");
> > > > +   PTS_WRITE_MSG("Caught alarm signal\n");
> > > > +           if (errno != EINTR) {
> > > > +                   perror("nanosleep() did not return success\n");
> > > > +                   return PTS_UNRESOLVED;
> > > > +           }
> > >
> > > Medium: PTS_WRITE_MSG() calls write() without preserving errno. If the
> > > second signal arrives after nanosleep() sets EINTR but before the new
> > > errno check, a failed handler write (e.g. EAGAIN on a full nonblocking
> > > stdout pipe) causes a spurious unresolved result even when both timers
> > > fired. Save errno on entry and restore it before returning in both
> > > handlers.
> >
> > The race condition pointed out by the AI seems plausible. Would it make
> > sense to save and restore errno in the signal handlers, like this:
> >
> 
> It seems very unlikely. I was thinking to move the print outside of signal
> handler if we want to address it.

Agreed, moving the prints from the handlers is the better fix. 

-- 
Regards,
Li Wang


More information about the ltp mailing list