(root)/
strace-6.5/
tests/
status-none-threads.c
       1  /*
       2   * Check status=none filtering when a non-leader thread invokes execve.
       3   *
       4   * Copyright (c) 2019 Paul Chaignon <paul.chaignon@gmail.com>
       5   * All rights reserved.
       6   *
       7   * SPDX-License-Identifier: GPL-2.0-or-later
       8   */
       9  
      10  #include "tests.h"
      11  #include <errno.h>
      12  #include <pthread.h>
      13  #include <stdio.h>
      14  #include <unistd.h>
      15  #include "scno.h"
      16  
      17  static pid_t leader;
      18  
      19  static void *
      20  thread(void *arg)
      21  {
      22  	struct timespec ts = { .tv_nsec = 100000000 };
      23  	(void) nanosleep(&ts, NULL);
      24  
      25  	printf("%-5d +++ superseded by execve in pid %u +++\n",
      26  	       leader, (int) syscall(__NR_gettid));
      27  
      28  	char *argv[] = {((char **) arg)[0], (char *) "0", NULL};
      29  	execve(argv[0], argv, NULL);
      30  	perror_msg_and_fail("execve");
      31  }
      32  
      33  int
      34  main(int ac, char **av)
      35  {
      36  	setvbuf(stdout, NULL, _IONBF, 0);
      37  	leader = getpid();
      38  
      39  	if (ac > 1) {
      40  		printf("%-5d +++ exited with 0 +++\n", leader);
      41  		return 0;
      42  	}
      43  
      44  	pthread_t t;
      45  	errno = pthread_create(&t, NULL, thread, av);
      46  	if (errno)
      47  		perror_msg_and_fail("pthread_create");
      48  
      49  	struct timespec ts = { .tv_sec = 123 };
      50  	(void) nanosleep(&ts, 0);
      51  
      52  	return 1;
      53  }