[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] mktime & nanosleep: make sure SIGALRM is not blocked
From: |
Eric Blake |
Subject: |
Re: [PATCH] mktime & nanosleep: make sure SIGALRM is not blocked |
Date: |
Mon, 18 May 2009 21:38:13 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Mike Frysinger on 5/18/2009 9:11 PM:
> Some systems might have SIGALRM blocked when running configure. If that
> is the case, the nanosleep() test will sleep for practically ever as the
> signal generated by alarm() is never delivered. As such, we should make
> sure to unblock SIGALRM before running any tests.
Thanks for the report.
> @@ -170,6 +170,10 @@ main ()
> /* This test makes some buggy mktime implementations loop.
> Give up after 60 seconds; a mktime slower than that
> isn't worth using anyway. */
> + sigset_t set;
> + sigemptyset (&set);
> + sigaddset (&set, SIGALRM);
> + sigprocmask (SIG_UNBLOCK, &set, NULL);
> alarm (60);
This won't work on platforms that have signal() but not sigprocmask().
Let's just reuse the test already present in other timeout situations,
such as in m4/strstr.m4.
...
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <signal.h> /* for signal */
#include <string.h> /* for memmem */
#include <stdlib.h> /* for malloc */
#include <unistd.h> /* for alarm */
]], [[size_t m = 1000000;
char *haystack = (char *) malloc (2 * m + 2);
char *needle = (char *) malloc (m + 2);
void *result = 0;
/* Failure to compile this test due to missing alarm is okay,
since all such platforms (mingw) also have quadratic strstr. */
signal (SIGALRM, SIG_DFL);
alarm (5);
...
We also need to make sure the test still gives the correct results on
mingw, which lacks alarm().
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkoSKaUACgkQ84KuGfSFAYCwKgCgpEEeAAtZI/WeiYT2b1VIkJwi
duQAn1NoT7fs/FCaFV/aQwqEOGzVb8ug
=ZldQ
-----END PGP SIGNATURE-----