1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/*
* Test PID namespace translation
*
* Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
* Copyright (c) 2020-2022 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef STRACE_PIDNS_H
# define STRACE_PIDNS_H
# ifdef PIDNS_TRANSLATION
# define PIDNS_TEST_INIT pidns_test_init()
# else
# define PIDNS_TEST_INIT
# endif
# include <sys/types.h>
enum pid_type {
PT_TID,
PT_TGID,
PT_PGID,
PT_SID,
PT_COUNT,
PT_NONE = -1
};
/* Prints leader (process tid) if pidns_test_init was called */
void pidns_print_leader(void);
/*
* Returns a static buffer containing the translation string of our PID.
*/
const char *pidns_pid2str(enum pid_type type);
/**
* Skips the test if NS_* ioctl commands are not supported by the kernel.
*/
void check_ns_ioctl(void);
/**
* Init pidns testing.
*
* Should be called at the beginning of the test's main function
*
* This function calls fork a couple of times, and returns in the child
* processes. These child processes are in a new PID namespace with different
* PID configurations (group leader, session leader, ...). If any child
* terminates with nonzero exit status the test is failed. Otherwise the test is
* successful, and the parent process exits with 0.
*/
void pidns_test_init(void);
#endif
|