1 /* SPDX-License-Identifier: GPL-2.0-or-later 2 * Copyright (c) 2015-2016 Cyril Hrubis <chrubis@suse.cz> 3 */ 4 5 #ifndef TST_PID_H__ 6 #define TST_PID_H__ 7 8 #include <sys/types.h> 9 10 /* 11 * Get a pid value not used by the OS 12 */ 13 pid_t tst_get_unused_pid_(void (*cleanup_fn)(void)); 14 15 /* 16 * Returns number of free pids by substarction of the number of pids 17 * currently used ('ps -eT') from max_pids 18 */ 19 int tst_get_free_pids_(void (*cleanup_fn)(void)); 20 21 #ifdef TST_TEST_H__ tst_get_unused_pid(void)22static inline pid_t tst_get_unused_pid(void) 23 { 24 return tst_get_unused_pid_(NULL); 25 } 26 tst_get_free_pids(void)27static inline int tst_get_free_pids(void) 28 { 29 return tst_get_free_pids_(NULL); 30 } 31 #else tst_get_unused_pid(void (* cleanup_fn)(void))32static inline pid_t tst_get_unused_pid(void (*cleanup_fn)(void)) 33 { 34 return tst_get_unused_pid_(cleanup_fn); 35 } 36 tst_get_free_pids(void (* cleanup_fn)(void))37static inline int tst_get_free_pids(void (*cleanup_fn)(void)) 38 { 39 return tst_get_free_pids_(cleanup_fn); 40 } 41 #endif 42 43 #endif /* TST_PID_H__ */ 44