(root)/
strace-6.5/
tests/
rt_tgsigqueueinfo.c
       1  /*
       2   * Check decoding of rt_tgsigqueueinfo syscall.
       3   *
       4   * Copyright (c) 2016 Dmitry V. Levin <ldv@strace.io>
       5   * Copyright (c) 2016-2021 The strace developers.
       6   * All rights reserved.
       7   *
       8   * SPDX-License-Identifier: GPL-2.0-or-later
       9   */
      10  
      11  #include "tests.h"
      12  #include "scno.h"
      13  #include "pidns.h"
      14  
      15  #include <errno.h>
      16  #include <signal.h>
      17  #include <stdio.h>
      18  #include <string.h>
      19  #include <unistd.h>
      20  
      21  static long
      22  k_tgsigqueueinfo(const pid_t tgid, const int tid, const int sig, const void *const info)
      23  {
      24  	return syscall(__NR_rt_tgsigqueueinfo,
      25  		       F8ILL_KULONG_MASK | tgid,
      26  		       F8ILL_KULONG_MASK | tid,
      27  		       F8ILL_KULONG_MASK | sig,
      28  		       info);
      29  }
      30  
      31  int
      32  main(void)
      33  {
      34  	PIDNS_TEST_INIT;
      35  
      36  	const struct sigaction sa = {
      37  		.sa_handler = SIG_IGN
      38  	};
      39  	if (sigaction(SIGUSR1, &sa, NULL))
      40  		perror_msg_and_fail("sigaction");
      41  
      42  	TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, info);
      43  	memset(info, 0, sizeof(*info));
      44  	info->si_signo = SIGUSR1;
      45  	info->si_errno = ENOENT;
      46  	info->si_code = SI_QUEUE;
      47  	info->si_pid = getpid();
      48  	info->si_uid = getuid();
      49  	info->si_value.sival_ptr =
      50  		(void *) (unsigned long) 0xdeadbeeffacefeedULL;
      51  
      52  	if (k_tgsigqueueinfo(getpid(), syscall(__NR_gettid), SIGUSR1, info))
      53  		(errno == ENOSYS ? perror_msg_and_skip : perror_msg_and_fail)(
      54  			"rt_tgsigqueueinfo");
      55  
      56  	pidns_print_leader();
      57  	printf("rt_tgsigqueueinfo(%d%s, %d%s, %s, {si_signo=%s"
      58  		", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%d%s"
      59  		", si_uid=%d, si_int=%d, si_ptr=%p}) = 0\n",
      60  		info->si_pid, pidns_pid2str(PT_TGID),
      61  		info->si_pid, pidns_pid2str(PT_TID),
      62  		"SIGUSR1", "SIGUSR1",
      63  		info->si_pid, pidns_pid2str(PT_TGID),
      64  		info->si_uid, info->si_value.sival_int,
      65  		info->si_value.sival_ptr);
      66  
      67  	pidns_print_leader();
      68  	puts("+++ exited with 0 +++");
      69  	return 0;
      70  }