diff options
| author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-12-23 19:07:10 -0800 |
|---|---|---|
| committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-01-06 09:29:45 +0100 |
| commit | 99e6defbe79d3a41f967b55d33ce1a856914e797 (patch) | |
| tree | 7d436f9a788bfd652a3a63714dcbd481e487ec4d /lib | |
| parent | cf93bc8df9f5f94a0aedc8b52bad0ad4e036737c (diff) | |
Use pthread calls instead of raw syscalls on non-Linux systems
Raw system calls aren't portable to other kernels.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/igt_core.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c index 40bc92fd..01fb4574 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -45,7 +45,11 @@ #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> +#ifdef __linux__ #include <sys/syscall.h> +#else +#include <pthread.h> +#endif #include <sys/utsname.h> #include <termios.h> #include <errno.h> @@ -1260,8 +1264,6 @@ static void igt_atexit_handler(void) static void fatal_sig_handler(int sig) { - pid_t pid, tid; - restore_all_sig_handler(); /* @@ -1270,11 +1272,20 @@ static void fatal_sig_handler(int sig) */ call_exit_handlers(sig); + { +#ifdef __linux__ /* Workaround cached PID and TID races on glibc and Bionic libc. */ - pid = syscall(SYS_getpid); - tid = syscall(SYS_gettid); + pid_t pid = syscall(SYS_getpid); + pid_t tid = syscall(SYS_gettid); - syscall(SYS_tgkill, pid, tid, sig); + syscall(SYS_tgkill, pid, tid, sig); +#else + pthread_t tid = pthread_self(); + union sigval value = { .sival_ptr = NULL }; + + pthread_sigqueue(tid, sig, value); +#endif + } } /** |
