From: Li Wang <li.wang@linux.dev>
To: linuxtestproject.agent@gmail.com
Cc: ltp@lists.linux.it
Subject: Re: [LTP] openposix: timers/twoevtimers: Wait for both timer signals
Date: Sat, 10 Oct 2026 17:06:49 +0800 [thread overview]
Message-ID: <asoAKV-Wd-TK5XUe@linux.dev> (raw)
In-Reply-To: <20261009172601.34695-1-linuxtestproject.agent@gmail.com>
Hi Jan,
linuxtestproject.agent@gmail.com wrote:
> Hi Jan,
>
> 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:
static void handler_abrt(int signo PTS_ATTRIBUTE_UNUSED)
{
+ int saved_errno = errno;
+
PTS_WRITE_MSG("Caught abort signal\n");
caughtabort++;
+
+ errno = saved_errno;
+
}
static void handler_alrm(int signo PTS_ATTRIBUTE_UNUSED)
{
+ int saved_errno = errno;
+
PTS_WRITE_MSG("Caught alarm signal\n");
caughtalarm++;
+
+ errno = saved_errno;
}
The rest part looks good to me.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-10-10 9:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 6:49 [LTP] [PATCH] openposix: timers/twoevtimers: Wait for both timer signals Jan Stancek via ltp
2026-10-09 10:09 ` [LTP] " linuxtestproject.agent
2026-10-09 10:52 ` [LTP] [PATCH v2] " Jan Stancek via ltp
2026-10-09 17:26 ` [LTP] " linuxtestproject.agent
2026-10-10 9:06 ` Li Wang [this message]
2026-10-10 9:42 ` Jan Stancek via ltp
2026-10-11 1:07 ` Li Wang
2026-10-12 4:56 ` [LTP] [PATCH v3] " Jan Stancek via ltp
2026-10-12 7:19 ` [LTP] " linuxtestproject.agent
2026-10-12 8:03 ` [LTP] [PATCH v4] " Jan Stancek via ltp
2026-10-12 9:33 ` Petr Vorel
2026-10-12 15:47 ` [LTP] " linuxtestproject.agent
2026-10-14 1:59 ` [LTP] [PATCH v4] " Li Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=asoAKV-Wd-TK5XUe@linux.dev \
--to=li.wang@linux.dev \
--cc=linuxtestproject.agent@gmail.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox