(root)/
strace-6.5/
tests-mx32/
vhangup.c
       1  /*
       2   * Check decoding of vhangup syscall.
       3   *
       4   * Copyright (c) 2016-2021 The strace developers.
       5   * All rights reserved.
       6   *
       7   * SPDX-License-Identifier: GPL-2.0-or-later
       8   */
       9  
      10  #include "tests.h"
      11  #include "scno.h"
      12  
      13  #include <stdio.h>
      14  #include <unistd.h>
      15  
      16  int
      17  main(void)
      18  {
      19  	if (setsid() == -1)
      20  		perror_msg_and_skip("setsid");
      21  
      22  	long rc = syscall(__NR_vhangup);
      23  
      24  	/*
      25  	 * On setsid() success, the new session has no controlling terminal,
      26  	 * therefore a subsequent vhangup() has nothing to hangup.
      27  	 *
      28  	 * The system call, however, returns 0 iff the calling process
      29  	 * has CAP_SYS_TTY_CONFIG capability.
      30  	 */
      31  	printf("vhangup() = %s\n", sprintrc(rc));
      32  
      33  	puts("+++ exited with 0 +++");
      34  	return 0;
      35  }