Home | History | Annotate | Download | only in lib
      1 /*
      2  * Copyright (c) 2016 Linux Test Project
      3  *
      4  * This program is free software;  you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License as published by
      6  * the Free Software Foundation; either version 2 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY;  without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     12  * the GNU General Public License for more details.
     13  */
     14 
     15 #include <stdlib.h>
     16 #include <sys/types.h>
     17 
     18 #include "tst_sig_proc.h"
     19 
     20 #define TST_NO_DEFAULT_MAIN
     21 #include "tst_test.h"
     22 
     23 pid_t create_sig_proc(int sig, int count, unsigned int usec)
     24 {
     25 	pid_t pid, cpid;
     26 
     27 	pid = getpid();
     28 	cpid = SAFE_FORK();
     29 
     30 	if (cpid == 0) {
     31 		while (count-- > 0) {
     32 			usleep(usec);
     33 			if (kill(pid, sig) == -1)
     34 				break;
     35 		}
     36 		exit(0);
     37 	}
     38 
     39 	return cpid;
     40 }
     41