File: kill.c

package info (click to toggle)
systemtap 4.8-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 39,000 kB
  • sloc: cpp: 78,785; ansic: 62,419; xml: 49,443; exp: 42,735; sh: 11,254; python: 3,062; perl: 2,252; tcl: 1,305; makefile: 1,072; lisp: 105; awk: 101; asm: 91; java: 56; sed: 16
file content (46 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* COVERAGE: kill */

#define _GNU_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <sys/syscall.h>

// To test for glibc support for kill:
//           _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE

#define GLIBC_SUPPORT \
    (_POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE)

int main()
{
  sigset_t mask;
  struct sigaction sa;
  pid_t pid;

  // Ignore SIGUSR1
  signal(SIGUSR1, SIG_IGN);

  pid = getpid();

  // Be sure we're in our own process group.
  setpgid(0, 0);

#ifdef GLIBC_SUPPORT
  kill(pid, SIGUSR1);
  //staptest// kill (NNNN, SIGUSR1) = 0

  // Normally We couldn't call kill() with -1 for a pid, since that
  // would send a signal to the make process and kill it. However,
  // since we also use an invalid signal number, this shouldn't cause
  // that problem.
  kill(-1, -1);
  //staptest// kill (-1, 0xffffffff) = -NNNN

  kill(pid, -1);
  //staptest// kill (NNNN, 0xffffffff) = -NNNN
#endif
  return 0;
}