<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - qemu using spice gl and sandbox resourcecontrol=deny crashes with SIGSYS on radeonsi"
href="https://bugs.freedesktop.org/show_bug.cgi?id=109695#c2">Comment # 2</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - qemu using spice gl and sandbox resourcecontrol=deny crashes with SIGSYS on radeonsi"
href="https://bugs.freedesktop.org/show_bug.cgi?id=109695">bug 109695</a>
from <span class="vcard"><a class="email" href="mailto:Ahzo@tutanota.com" title="Ahzo@tutanota.com">Ahzo@tutanota.com</a>
</span></b>
<pre>To check for the availability of the syscall, one can try it in a child process
and see if the child is terminated by a signal, e.g. like this:
#include <stdbool.h>
#include <unistd.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/wait.h>
static bool
can_set_affinity()
{
pid_t pid = fork();
int status = 0;
if (!pid) {
/* Disable coredumps, because a SIGSYS crash is expected. */
struct rlimit limit = { 0 };
limit.rlim_cur = 1;
limit.rlim_max = 1;
setrlimit(RLIMIT_CORE, &limit);
/* Test the syscall in the child process. */
syscall(SYS_sched_setaffinity, 0, 0, 0);
_exit(0);
} else if (pid < 0) {
return false;
}
if (waitpid(pid, &status, 0) < 0) {
return false;
}
if (WIFSIGNALED(status)) {
/* The child process was terminated by a signal,
* thus the syscall cannot be used.
*/
return false;
}
return true;
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>