1 //===-- Linux implementation of signal ------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "src/signal/signal.h"
10 #include "src/signal/sigaction.h"
12 #include "src/__support/common.h"
16 namespace LIBC_NAMESPACE
{
18 LLVM_LIBC_FUNCTION(sighandler_t
, signal
, (int signum
, sighandler_t handler
)) {
19 struct sigaction action
, old
;
20 action
.sa_handler
= handler
;
21 action
.sa_flags
= SA_RESTART
;
22 // Errno will already be set so no need to worry about changing errno here.
23 return LIBC_NAMESPACE::sigaction(signum
, &action
, &old
) == -1
28 } // namespace LIBC_NAMESPACE