• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2016 Linux Test Project
4  */
5 
6 #include <stdlib.h>
7 #include <sys/types.h>
8 
9 #include "tst_sig_proc.h"
10 
11 #define TST_NO_DEFAULT_MAIN
12 #include "tst_test.h"
13 
create_sig_proc(int sig,int count,unsigned int usec)14 pid_t create_sig_proc(int sig, int count, unsigned int usec)
15 {
16 	pid_t pid, cpid;
17 
18 	pid = getpid();
19 	cpid = SAFE_FORK();
20 
21 	if (cpid == 0) {
22 		while (count-- > 0) {
23 			usleep(usec);
24 			if (kill(pid, sig) == -1)
25 				break;
26 		}
27 		exit(0);
28 	}
29 
30 	return cpid;
31 }
32