summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/emscripten/system/lib/libc/sigaction.c
blob: 080ad45c5a815e2f416e0919d77da5ae08ae3627 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * Copyright 2021 The Emscripten Authors.  All rights reserved.
 * Emscripten is available under two separate licenses, the MIT license and the
 * University of Illinois/NCSA Open Source License.  Both these licenses can be
 * found in the LICENSE file.
 */

#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include "libc.h"

struct sigaction __sig_actions[_NSIG];

int __sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) {
  if (sig < 0 || sig >= _NSIG) {
    errno = EINVAL;
    return -1;
  }

  if (old) {
    *old = __sig_actions[sig];
  }

  if (sa) {
    __sig_actions[sig] = *sa;
  }

  return 0;
}

weak_alias(__sigaction, sigaction);