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