At least mingw64 has 8-byte pid_t but only 4-byte long. Silent truncation to int in printing a pid value with %d risks killing the wrong process. But rather than try to futz with determining the maximum pid_t, it is simpler to just cap things by realizing that this test is already skipped on mingw64, so adding a sanity check bounds comparison (and hard-coding the result rather than dragging in headers for INT_MAX) is just as effective at avoiding theoretical problems with no real loss in test coverage.
* tests/test-sigprocmask.c (main): Add range check. Signed-off-by: Eric Blake <ebl...@redhat.com> --- I noticed this while investigating a test failure on Cygwin 1.7.17. Alas, this doesn't help Cygwin, but I'm thinking that recent changes in Cygwin signal-handling code have introduced an unintentional regression, and that it is not something gnulib can (or should) work around. ChangeLog | 3 +++ tests/test-sigprocmask.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41fc6ac..df7999e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2012-12-31 Eric Blake <ebl...@redhat.com> + sigprocmask-tests: skip test if pid is unexpectedly large + * tests/test-sigprocmask.c (main): Add range check. + git-version-gen: avoid test -z portability glitch * build-aux/git-version-gen: Prefer portable test spelling, since git-version-gen is run on more than just developer machines. diff --git a/tests/test-sigprocmask.c b/tests/test-sigprocmask.c index 55d11b0..5b67df4 100644 --- a/tests/test-sigprocmask.c +++ b/tests/test-sigprocmask.c @@ -44,9 +44,15 @@ int main (int argc, char *argv[]) { sigset_t set; - int pid = getpid (); + pid_t pid = getpid (); char command[80]; + if (sizeof pid > sizeof (int) && pid > 0x7fffffff) + { + fputs ("Skipping test: pid too large\n", stderr); + return 77; + } + signal (SIGINT, sigint_handler); sigemptyset (&set); @@ -60,7 +66,7 @@ main (int argc, char *argv[]) ASSERT (sigprocmask (SIG_BLOCK, &set, NULL) == 0); /* Request a SIGINT signal from outside. */ - sprintf (command, "sh -c 'sleep 1; kill -%d %d' &", SIGINT, pid); + sprintf (command, "sh -c 'sleep 1; kill -%d %d' &", SIGINT, (int) pid); ASSERT (system (command) == 0); /* Wait. */ -- 1.8.0.2