(root)/
strace-6.5/
tests/
rt_sigreturn.c
       1  /*
       2   * Copyright (c) 2015-2021 Dmitry V. Levin <ldv@strace.io>
       3   * All rights reserved.
       4   *
       5   * SPDX-License-Identifier: GPL-2.0-or-later
       6   */
       7  
       8  #include "tests.h"
       9  #include <signal.h>
      10  #include <stdio.h>
      11  #include <stdlib.h>
      12  
      13  #ifdef ASM_SIGRTMIN
      14  # define RT_0 ASM_SIGRTMIN
      15  #else
      16  /* Linux kernel >= 3.18 defines SIGRTMIN to 32 on all architectures. */
      17  # define RT_0 32
      18  #endif
      19  
      20  static void
      21  handler(int no, siginfo_t *si, void *uc)
      22  {
      23  }
      24  
      25  int
      26  main(void)
      27  {
      28  	static sigset_t set;
      29  	sigemptyset(&set);
      30  	sigaddset(&set, SIGINT);
      31  	sigaddset(&set, SIGUSR2);
      32  	sigaddset(&set, SIGCHLD);
      33  	sigaddset(&set, RT_0 +  3);
      34  	sigaddset(&set, RT_0 +  4);
      35  	sigaddset(&set, RT_0 +  5);
      36  	sigaddset(&set, RT_0 + 26);
      37  	sigaddset(&set, RT_0 + 27);
      38  	if (sigprocmask(SIG_SETMASK, &set, NULL))
      39  		perror_msg_and_fail("sigprocmask");
      40  	sigemptyset(&set);
      41  
      42  	static const struct sigaction sa = {
      43  		.sa_sigaction = handler,
      44  		.sa_flags = SA_SIGINFO
      45  	};
      46  	if (sigaction(SIGUSR1, &sa, NULL))
      47  		perror_msg_and_fail("sigaction");
      48  
      49  	if (raise(SIGUSR1))
      50  		perror_msg_and_fail("raise");
      51  
      52  	static const char *const sigs =
      53  		(SIGUSR2 < SIGCHLD) ? "INT USR2 CHLD" : "INT CHLD USR2";
      54  	static const char *const rt_sigs = "RT_3 RT_4 RT_5 RT_26 RT_27";
      55  	printf("rt_sigreturn({mask=[%s %s]}) = 0\n", sigs, rt_sigs);
      56  
      57  	puts("+++ exited with 0 +++");
      58  	return 0;
      59  }