diff options
Diffstat (limited to 'tools/testing/selftests/sched/cs_prctl_test.c')
| -rw-r--r-- | tools/testing/selftests/sched/cs_prctl_test.c | 28 | 
1 files changed, 18 insertions, 10 deletions
| diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c index 7db9cf822dc7..8109b17dc764 100644 --- a/tools/testing/selftests/sched/cs_prctl_test.c +++ b/tools/testing/selftests/sched/cs_prctl_test.c @@ -62,6 +62,17 @@ enum pid_type {PIDTYPE_PID = 0, PIDTYPE_TGID, PIDTYPE_PGID};  const int THREAD_CLONE_FLAGS = CLONE_THREAD | CLONE_SIGHAND | CLONE_FS | CLONE_VM | CLONE_FILES; +struct child_args { +	int num_threads; +	int pfd[2]; +	int cpid; +	int thr_tids[MAX_THREADS]; +}; + +static struct child_args procs[MAX_PROCESSES]; +static int num_processes = 2; +static int need_cleanup = 0; +  static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4,  		  unsigned long arg5)  { @@ -78,8 +89,14 @@ static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned l  #define handle_error(msg) __handle_error(__FILE__, __LINE__, msg)  static void __handle_error(char *fn, int ln, char *msg)  { +	int pidx;  	printf("(%s:%d) - ", fn, ln);  	perror(msg); +	if (need_cleanup) { +		for (pidx = 0; pidx < num_processes; ++pidx) +			kill(procs[pidx].cpid, 15); +		need_cleanup = 0; +	}  	exit(EXIT_FAILURE);  } @@ -106,13 +123,6 @@ static unsigned long get_cs_cookie(int pid)  	return cookie;  } -struct child_args { -	int num_threads; -	int pfd[2]; -	int cpid; -	int thr_tids[MAX_THREADS]; -}; -  static int child_func_thread(void __attribute__((unused))*arg)  {  	while (1) @@ -212,10 +222,7 @@ void _validate(int line, int val, char *msg)  int main(int argc, char *argv[])  { -	struct child_args procs[MAX_PROCESSES]; -  	int keypress = 0; -	int num_processes = 2;  	int num_threads = 3;  	int delay = 0;  	int res = 0; @@ -262,6 +269,7 @@ int main(int argc, char *argv[])  	printf("\n## Create a thread/process/process group hiearchy\n");  	create_processes(num_processes, num_threads, procs); +	need_cleanup = 1;  	disp_processes(num_processes, procs);  	validate(get_cs_cookie(0) == 0); |