(root)/
strace-6.5/
tests/
set_sigign.c
       1  /*
       2   * Execute a command with a signal handler set to SIG_IGN/SIG_DFL.
       3   *
       4   * Copyright (c) 2017-2021 Dmitry V. Levin <ldv@strace.io>
       5   * All rights reserved.
       6   *
       7   * SPDX-License-Identifier: GPL-2.0-or-later
       8   */
       9  
      10  #include "tests.h"
      11  #include <signal.h>
      12  #include <stdlib.h>
      13  #include <unistd.h>
      14  
      15  int
      16  main(int ac, char **av)
      17  {
      18  	if (ac < 4)
      19  		error_msg_and_fail("usage: set_sigign 0|1 signum path...");
      20  
      21  	const int ign = atoi(av[1]);
      22  	const int signum = atoi(av[2]);
      23  
      24  	if (signal(signum, ign ? SIG_IGN : SIG_DFL) == SIG_ERR)
      25  		perror_msg_and_fail("signal: %s", av[2]);
      26  
      27  	execvp(av[3], av + 3);
      28  	perror_msg_and_fail("execvp: %s", av[3]);
      29  }