Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/libc/sigtimedwait.c
6162 views
1
/*
2
* Copyright 2021 The Emscripten Authors. All rights reserved.
3
* Emscripten is available under two separate licenses, the MIT license and the
4
* University of Illinois/NCSA Open Source License. Both these licenses can be
5
* found in the LICENSE file.
6
*/
7
8
#include <signal.h>
9
#include <errno.h>
10
#include "syscall.h"
11
#include "libc.h"
12
13
extern sigset_t __sig_pending;
14
15
int sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict timeout) {
16
for (int sig = 0; sig < _NSIG; sig++) {
17
if (sigismember(mask, sig) && sigismember(&__sig_pending, sig)) {
18
if (si) {
19
siginfo_t t = {0};
20
*si = t;
21
}
22
sigdelset(&__sig_pending, sig);
23
return sig;
24
}
25
}
26
27
errno = EINVAL;
28
return -1;
29
}
30
31