(root)/
strace-6.5/
tests-mx32/
kill.c
       1  /*
       2   * Check decoding of kill syscall.
       3   *
       4   * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@strace.io>
       5   * Copyright (c) 2016 Fei Jie <feij.fnst@cn.fujitsu.com>
       6   * Copyright (c) 2016-2021 The strace developers.
       7   * All rights reserved.
       8   *
       9   * SPDX-License-Identifier: GPL-2.0-or-later
      10   */
      11  
      12  #include "tests.h"
      13  #include "scno.h"
      14  #include "pidns.h"
      15  
      16  #include <signal.h>
      17  #include <stdio.h>
      18  #include <unistd.h>
      19  
      20  static void
      21  handler(int sig)
      22  {
      23  }
      24  
      25  int
      26  main(void)
      27  {
      28  	PIDNS_TEST_INIT;
      29  
      30  	const struct sigaction act = { .sa_handler = handler };
      31  	if (sigaction(SIGALRM, &act, NULL))
      32  		perror_msg_and_fail("sigaction");
      33  
      34  	sigset_t mask;
      35  	sigemptyset(&mask);
      36  	sigaddset(&mask, SIGALRM);
      37  	if (sigprocmask(SIG_UNBLOCK, &mask, NULL))
      38  		perror_msg_and_fail("sigprocmask");
      39  
      40  	const int pid = getpid();
      41  	const char *pid_str = pidns_pid2str(PT_TGID);
      42  	long rc = syscall(__NR_kill, pid, (long) 0xdefaced00000000ULL | SIGALRM);
      43  	pidns_print_leader();
      44  	printf("kill(%d%s, SIGALRM) = %ld\n", pid, pid_str, rc);
      45  
      46  	const long big_pid = (long) 0xfacefeedbadc0dedULL;
      47  	const long big_sig = (long) 0xdeadbeefcafef00dULL;
      48  	rc = syscall(__NR_kill, big_pid, big_sig);
      49  	pidns_print_leader();
      50  	printf("kill(%d, %d) = %ld %s (%m)\n",
      51  	       (int) big_pid, (int) big_sig, rc, errno2name());
      52  
      53  	rc = syscall(__NR_kill, (long) 0xdefaced00000000ULL | pid, 0);
      54  	pidns_print_leader();
      55  	printf("kill(%d%s, 0) = %ld\n", pid, pid_str, rc);
      56  
      57  	pidns_print_leader();
      58  	puts("+++ exited with 0 +++");
      59  	return 0;
      60  }