Back to index

glibc  2.9
Defines | Functions
tst-fork4.c File Reference
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 64 of file tst-fork4.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 30 of file tst-fork4.c.

{
  pthread_t me = pthread_self ();

  pid_t pid = fork ();

  if (pid < 0)
    {
      printf ("fork: %m\n");
      return 1;
    }

  if (pid == 0)
    {
      int err = pthread_kill (me, SIGTERM);
      printf ("pthread_kill returned: %s\n", strerror (err));
      return 3;
    }

  int status;
  errno = 0;
  if (wait (&status) != pid)
    printf ("wait failed: %m\n");
  else if (WIFSIGNALED (status) && WTERMSIG (status) == SIGTERM)
    {
      printf ("child correctly died with SIGTERM\n");
      return 0;
    }
  else
    printf ("child died with bad status %#x\n", status);

  return 1;
}

Here is the call graph for this function: