Back to index

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

Go to the source code of this file.

Defines

#define THE_SIGNAL   SIGUSR1
#define TEST_FUNCTION   do_test ()

Functions

static void final_test (void)
static void * tf (void *a)
int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 100 of file tst-basic4.c.

#define THE_SIGNAL   SIGUSR1

Function Documentation

int do_test ( void  )

Definition at line 81 of file tst-basic4.c.

{
  pthread_t th;

  if (pthread_create (&th, NULL, tf, NULL) != 0)
    {
      puts ("create failed");
      _exit (1);
    }

  if (pthread_join (th, NULL) != 0)
    {
      puts ("join failed");
      exit (1);
    }

  return 0;
}

Here is the call graph for this function:

static void final_test ( void  ) [static]

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

{
  puts ("final_test has been called");

#define THE_SIGNAL SIGUSR1
  kill (getpid (), SIGUSR1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void* tf ( void *  a) [static]

Definition at line 40 of file tst-basic4.c.

{
  pid_t pid = fork ();
  if (pid == -1)
    {
      puts ("fork failed");
      exit (1);
    }

  if (pid == 0)
    {
      atexit (final_test);

      pthread_exit (NULL);
    }

  int r;
  int e = TEMP_FAILURE_RETRY (waitpid (pid, &r, 0));
  if (e != pid)
    {
      puts ("waitpid failed");
      exit (1);
    }

  if (! WIFSIGNALED (r))
    {
      puts ("child not signled");
      exit (1);
    }

  if (WTERMSIG (r) != THE_SIGNAL)
    {
      puts ("child's termination signal wrong");
      exit (1);
    }

  return NULL;
}

Here is the call graph for this function: