1/******************************************************************************/ 2/* Copyright (c) Crackerjack Project., 2007 */ 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/* You should have received a copy of the GNU General Public License */ 15/* along with this program; if not, write to the Free Software */ 16/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 17/* */ 18/******************************************************************************/ 19/******************************************************************************/ 20/* */ 21/* File: rt_sigqueueinfo01.c */ 22/* */ 23/* Description: This tests the rt_sigqueueinfo() syscall. */ 24/* rt_sigqueueinfo() Send signal information to a signal */ 25/* */ 26/* Usage: <for command-line> */ 27/* rt_sigqueueinfo01 [-c n] [-e][-i n] [-I x] [-p x] [-t] */ 28/* where, -c n : Run n copies concurrently. */ 29/* -e : Turn on errno logging. */ 30/* -i n : Execute test n times. */ 31/* -I x : Execute test for x seconds. */ 32/* -P x : Pause for x seconds between iterations. */ 33/* -t : Turn on syscall timing. */ 34/* */ 35/* Total Tests: 2 */ 36/* */ 37/* Test Name: rt_sigqueueinfo01 */ 38/* History: Porting from Crackerjack to LTP is done by */ 39/* Manas Kumar Nayak maknayak@in.ibm.com> */ 40/******************************************************************************/ 41#include <sys/wait.h> 42#include <stdio.h> 43#include <signal.h> 44#include <err.h> 45#include <errno.h> 46#include <stdlib.h> 47#include <unistd.h> 48#include <sys/syscall.h> 49#include <string.h> 50 51#include "test.h" 52#include "linux_syscall_numbers.h" 53 54char *TCID = "rt_sigqueueinfo01"; 55int testno; 56int TST_TOTAL = 2; 57 58void cleanup(void) 59{ 60 61 tst_rmdir(); 62 63} 64 65void setup(void) 66{ 67 TEST_PAUSE; 68 tst_tmpdir(); 69} 70 71int main(void) 72{ 73 int status; 74 pid_t pid; 75 pid = getpid(); 76 siginfo_t uinfo; 77 78 tst_count = 0; 79 for (testno = 0; testno < TST_TOTAL; ++testno) { 80 TEST(pid = fork()); 81 setup(); 82 if (TEST_RETURN < 0) 83 tst_brkm(TFAIL | TTERRNO, cleanup, "fork failed"); 84 else if (TEST_RETURN == 0) { 85 uinfo.si_errno = 0; 86 uinfo.si_code = SI_QUEUE; 87 TEST(ltp_syscall(__NR_rt_sigqueueinfo, getpid(), 88 SIGCHLD, &uinfo)); 89 if (TEST_RETURN != 0) 90 err(1, "rt_sigqueueinfo"); 91 exit(0); 92 } else { 93 wait(&status); 94 if (WIFEXITED(status) && WEXITSTATUS(status) == 0) 95 tst_resm(TPASS, "Test Succeeded"); 96 else 97 tst_resm(TFAIL, "Test Failed"); 98 } 99 cleanup(); 100 } 101 tst_exit(); 102} 103