2 * Copyright 2014 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
12 #include "native_client/src/include/nacl_assert.h"
13 #include "native_client/src/nonsfi/linux/linux_sys_private.h"
14 #include "native_client/src/nonsfi/linux/linux_syscall_defines.h"
15 #include "native_client/src/nonsfi/linux/linux_syscall_structs.h"
17 static jmp_buf g_jmp_buf;
19 static void return_from_signal_handler(int signo, linux_siginfo_t *info,
21 ASSERT_EQ(signo, SIGSEGV);
22 ASSERT_NE(info, NULL);
23 ASSERT_EQ(info->si_signo, SIGSEGV);
24 ASSERT_NE(data, NULL);
25 longjmp(g_jmp_buf, 42);
28 int main(int argc, char *argv[]) {
29 struct linux_sigaction sa;
30 memset(&sa, 0, sizeof(sa));
31 sa.sa_sigaction = return_from_signal_handler;
32 sa.sa_flags = LINUX_SA_SIGINFO;
33 sigset_t *mask = (sigset_t *)&sa.sa_mask;
35 sigaddset(mask, LINUX_SIGSEGV);
37 int rc = linux_sigaction(LINUX_SIGSEGV, &sa, NULL);
40 rc = setjmp(g_jmp_buf);
43 *(volatile int *) 0 = 0;
44 _exit(1); /* Shouldn't reach here. */
50 * We do not test oldact (the third argument of sigaction) as user
51 * mode qemu seems not to support it and crash with it.