| 1 |
/* COVERAGE: kill */ |
| 2 |
|
| 3 |
#define _GNU_SOURCE |
| 4 |
#include <stdio.h> |
| 5 |
#include <sys/types.h> |
| 6 |
#include <unistd.h> |
| 7 |
#include <signal.h> |
| 8 |
#include <string.h> |
| 9 |
#include <sys/syscall.h> |
| 10 |
|
| 11 |
// To test for glibc support for kill: |
| 12 |
// _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE |
| 13 |
|
| 14 |
#define GLIBC_SUPPORT \ |
| 15 |
(_POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE) |
| 16 |
|
| 17 |
int main() |
| 18 |
{ |
| 19 |
sigset_t mask; |
| 20 |
struct sigaction sa; |
| 21 |
pid_t pid; |
| 22 |
|
| 23 |
// Ignore SIGUSR1 |
| 24 |
signal(SIGUSR1, SIG_IGN); |
| 25 |
|
| 26 |
pid = getpid(); |
| 27 |
|
| 28 |
// Be sure we're in our own process group. |
| 29 |
setpgid(0, 0); |
| 30 |
|
| 31 |
#ifdef GLIBC_SUPPORT |
| 32 |
kill(pid, SIGUSR1); |
| 33 |
//staptest// kill (NNNN, SIGUSR1) = 0 |
| 34 |
|
| 35 |
// Normally We couldn't call kill() with -1 for a pid, since that |
| 36 |
// would send a signal to the make process and kill it. However, |
| 37 |
// since we also use an invalid signal number, this shouldn't cause |
| 38 |
// that problem. |
| 39 |
kill(-1, -1); |
| 40 |
//staptest// kill (-1, 0xffffffff) = -NNNN |
| 41 |
|
| 42 |
kill(pid, -1); |
| 43 |
//staptest// kill (NNNN, 0xffffffff) = -NNNN |
| 44 |
#endif |
| 45 |
return 0; |
| 46 |
} |