Add more raw system calls to redbean

We now have execve, setitimer, sigaction, sigsuspend, and sigprocmask.
This commit is contained in:
Justine Tunney 2022-04-13 14:43:42 -07:00
parent 281a0f2730
commit fb7e8ef1e6
8 changed files with 329 additions and 73 deletions

View file

@ -45,7 +45,7 @@ static textwindows inline bool HasWorkingConsole(void) {
*/
int raise(int sig) {
int rc, event;
STRACE("raise(%G) → [...]", sig);
STRACE("raise(%G) → ...", sig);
if (sig == SIGTRAP) {
DebugBreak();
rc = 0;
@ -75,6 +75,6 @@ int raise(int sig) {
rc = __sig_raise(sig, SI_USER);
}
}
STRACE("[...] raise(%G) → %d% m", sig, rc);
STRACE("...raise(%G) → %d% m", sig, rc);
return rc;
}

View file

@ -62,8 +62,6 @@ int sigprocmask(int how, const sigset_t *opt_set, sigset_t *opt_out_oldset) {
char buf[2][41];
int res, rc, arg1;
const sigset_t *arg2;
STRACE("sigprocmask(%s, %s, [...]", DescribeHow(howbuf, how),
__strace_sigset(buf[0], sizeof(buf[0]), 0, opt_set));
sigemptyset(&old);
if (IsAsan() &&
((opt_set && !__asan_is_valid(opt_set, sizeof(*opt_set))) ||
@ -94,7 +92,7 @@ int sigprocmask(int how, const sigset_t *opt_set, sigset_t *opt_out_oldset) {
if (rc != -1 && opt_out_oldset) {
*opt_out_oldset = old;
}
STRACE("[...] sigprocmask(%s, %s, [%s]) → %d% m", DescribeHow(howbuf, how),
STRACE("sigprocmask(%s, %s, [%s]) → %d% m", DescribeHow(howbuf, how),
__strace_sigset(buf[0], sizeof(buf[0]), 0, opt_set),
__strace_sigset(buf[1], sizeof(buf[1]), rc, opt_out_oldset), rc);
return rc;

View file

@ -32,6 +32,9 @@
/**
* Blocks until SIG MASK is delivered to process.
*
* This temporarily replaces the signal mask until a signal that it
* doesn't contain is delivered.
*
* @param ignore is a bitset of signals to block temporarily, which if
* NULL is equivalent to passing an empty signal set
* @return -1 w/ EINTR (or possibly EFAULT)
@ -43,8 +46,7 @@ int sigsuspend(const sigset_t *ignore) {
char buf[41];
long ms, totoms;
sigset_t save, mask, *arg;
STRACE("sigsuspend(%s) → [...]",
__strace_sigset(buf, sizeof(buf), 0, ignore));
STRACE("sigsuspend(%s) → ...", __strace_sigset(buf, sizeof(buf), 0, ignore));
if (IsAsan() && ignore && !__asan_is_valid(ignore, sizeof(*ignore))) {
rc = efault();
} else if (IsXnu() || IsOpenbsd()) {
@ -79,7 +81,7 @@ int sigsuspend(const sigset_t *ignore) {
ms += __SIG_POLLING_INTERVAL_MS;
if (ms >= __SIG_LOGGING_INTERVAL_MS) {
totoms += ms, ms = 0;
STRACE("[...] sigsuspending for %'lums...", totoms);
STRACE("... sigsuspending for %'lums...", totoms);
}
#endif
} while (1);
@ -89,6 +91,6 @@ int sigsuspend(const sigset_t *ignore) {
// TODO(jart): sigsuspend metal support
rc = enosys();
}
STRACE("[...] sigsuspend → %d% m", rc);
STRACE("...sigsuspend → %d% m", rc);
return rc;
}