(root)/
strace-6.5/
tests/
sleep.c
       1  /*
       2   * A simple nanosleep based sleep(1) replacement.
       3   *
       4   * Copyright (c) 2016-2018 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  
      14  #ifdef __NR_nanosleep
      15  
      16  # include <stdlib.h>
      17  # include <unistd.h>
      18  
      19  # include "kernel_old_timespec.h"
      20  
      21  int
      22  main(int ac, char **av)
      23  {
      24  	if (ac < 2)
      25  		error_msg_and_fail("missing operand");
      26  
      27  	if (ac > 2)
      28  		error_msg_and_fail("extra operand");
      29  
      30  	kernel_old_timespec_t ts = { atoi(av[1]), 0 };
      31  
      32  	if (syscall(__NR_nanosleep, (unsigned long) &ts, 0))
      33  		perror_msg_and_fail("nanosleep");
      34  
      35  	return 0;
      36  }
      37  
      38  #else
      39  
      40  SKIP_MAIN_UNDEFINED("__NR_nanosleep")
      41  
      42  #endif