feat(xce-test-cli-ux): fix SIGINT install to guarantee EINTR, add accessor

Replaces the bare signal(SIGINT, sigbreak) install with sigaction() and
SA_RESTART cleared, so a blocking read reliably returns EINTR instead of
being silently restarted by glibc's BSD signal() semantics. Adds
xcetest_interrupted() as a read-only accessor over the existing break_out
flag for the interruptible-call adapter (tasks 1.4/1.5) to consume.
Proven by a real fork+SIGINT+blocked-read test that first demonstrates
the old bug, then the fix. 1280/1280 controller suite passing (+2).

Task 1.3 of .kiro/specs/xce-test-cli-ux/tasks.md.
Requirements: 9.9

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jaMf9QEwpugH2W9KAuc7f
This commit is contained in:
Rongsong Shen 2026-09-09 08:03:30 +00:00
parent 89af46af3e
commit b4f5a460fc
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
6 changed files with 259 additions and 2 deletions

View file

@ -34,6 +34,7 @@
#include "resval_typeresolve.h" /* resval_resolve_type (resource-value-verification task 2.1) */
#include "xce/cluster.h" /* xce_parse_peers, xce_cluster_config_t */
#include "xce/types.h"
#include "xcetest_interrupt.h" /* xcetest_install_sigint, xcetest_interrupted (xce-test-cli-ux task 1.3) */
typedef int (*cmd_func_t)(int, char*[]);
@ -705,6 +706,13 @@ static struct argp argp = { options, parse_opt, args_doc, doc };
void sigbreak(int signo) { break_out = 1; }
/* xce-test-cli-ux task 1.3, Requirement 9.9: read-only accessor over
* `break_out` for code outside this file (interruptcall.c, task 1.4) to
* poll -- see xcetest_interrupt.h's file-header comment for the full
* contract (pure read, no reset side effect, break_out's own reset stays
* test.c-private). */
int xcetest_interrupted(void) { return break_out; }
static char* get_setting(char* key)
{
int i;
@ -4454,7 +4462,16 @@ int main(int argc, char* argv[])
mylog_init(logfile, loglevel, logsize, logcount);
signal(SIGINT, sigbreak);
/* xce-test-cli-ux task 1.3, Requirement 9.9: replaces the former bare
* `signal(SIGINT, sigbreak);` call. glibc's signal() installs with
* SA_RESTART SET (BSD semantics), which silently restarts a blocking
* slow syscall (read(), etc.) interrupted by SIGINT instead of
* returning EINTR -- see xcetest_interrupt.h's file header for the
* full rationale. xcetest_install_sigint() installs the same
* sigbreak() handler via sigaction() with SA_RESTART explicitly
* cleared, so a later blocking read (e.g. the confirmation prompt
* built on top of this task) reliably observes EINTR. */
xcetest_install_sigint(sigbreak);
memset(&run_jobs, 0x0, sizeof(run_jobs));
memset(&run_tasks, 0x0, sizeof(run_tasks));