emscripten-core / emscripten-core/emscripten

nanosleep autoconf check hangs forever

Open
#12,415 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I tried to build [GNU diffutils](https://www.gnu.org/software/diffutils/) with emscripten
```
checking for library containing nanosleep... none required
checking for working nanosleep..
```

During an out-of-tree configure, this nanosleep check hangs forever.

Here is a zip with conftest.c:
[diffutils.zip](https://github.com/emscripten-core/emscripten/files/5320262/diffutils.zip)
```cpp

#include
#include
#include
#if HAVE_SYS_TIME_H
#include
#endif
#include
#include
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
#define TYPE_MAXIMUM(t) ((t) (! TYPE_SIGNED (t) ? (t) -1 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))

#if HAVE_DECL_ALARM
static void
check_for_SIGALRM (int sig)
{
if (sig != SIGALRM)
_exit (1);
}
#endif

int
main ()
{
static struct timespec ts_sleep;
static struct timespec ts_remaining;
/* Test for major problems first. */
if (! nanosleep)
return 2;
ts_sleep.tv_sec = 0;
ts_sleep.tv_nsec = 1;
#if HAVE_DECL_ALARM
{
static struct sigaction act;
act.sa_handler = check_for_SIGALRM;
sigemptyset (&act.sa_mask);
sigaction (SIGALRM, &act, NULL);
alarm (1);
if (nanosleep (&ts_sleep, NULL) != 0)
return 3;
/* Test for a minor problem: the handling of large arguments. */
ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
ts_sleep.tv_nsec = 999999999;
alarm (1);
if (nanosleep (&ts_sleep, &ts_remaining) != -1)
return 4;
if (errno != EINTR)
return 5;
if (ts_remaining.tv_sec <= TYPE_MAXIMUM (time_t) - 10)
return 6;
}
#else /* A simpler test for native Windows. */
if (nanosleep (&ts_sleep, &ts_remaining) < 0)
return 3;
#endif
return 0;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.