2 * Copyright 2002-2011, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
6 * Daniel Reinhold, danielre@users.sf.net
7 * Ingo Weinhold, ingo_weinhold@gmx.de
16 #include <symbol_versioning.h>
18 #include <errno_private.h>
19 #include <signal_private.h>
23 signal_common(int signal
, __sighandler_t signalHandler
, int flags
)
25 struct sigaction newAction
, oldAction
;
27 // setup the replacement sigaction
28 newAction
.sa_handler
= signalHandler
;
29 newAction
.sa_mask
= 0;
30 newAction
.sa_flags
= flags
;
32 if (__sigaction(signal
, &newAction
, &oldAction
) != 0)
35 // success, return the original handler
36 return oldAction
.sa_handler
;
41 __signal_beos(int signal
, __sighandler_t signalHandler
)
44 if (signal
< 0 || signal
> MAX_SIGNAL_NUMBER_BEOS
) {
49 // set the signal handler
50 __sighandler_t result
= signal_common(signal
, signalHandler
,
51 SA_BEOS_COMPATIBLE_HANDLER
);
52 if (result
== SIG_ERR
)
55 // If the signal is SIGSEGV, set the same signal handler for SIGBUS. Those
56 // constants had the same value under BeOS.
57 if (signal
== SIGSEGV
)
58 signal_common(SIGBUS
, signalHandler
, SA_BEOS_COMPATIBLE_HANDLER
);
65 __signal(int signal
, __sighandler_t signalHandler
)
67 return signal_common(signal
, signalHandler
, 0);
71 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__signal_beos", "signal@", "BASE");
73 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__signal", "signal@@", "1_ALPHA4");