Back to index

glibc  2.9
Defines | Functions | Variables
tst-kill1.c File Reference
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define EXPECTED_SIGNAL   SIGUSR1
#define TEST_FUNCTION   do_test ()

Functions

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

Variables

static pthread_cond_t c = PTHREAD_COND_INITIALIZER
static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER
static pthread_barrier_t b

Define Documentation

#define EXPECTED_SIGNAL   SIGUSR1

Definition at line 98 of file tst-kill1.c.

#define TEST_FUNCTION   do_test ()

Definition at line 99 of file tst-kill1.c.


Function Documentation

int do_test ( void  )

Definition at line 54 of file tst-kill1.c.

{
  pthread_t th;

  if (pthread_barrier_init (&b, NULL, 2) != 0)
    {
      puts ("barrier_init failed");
      exit (1);
    }

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

  int e = pthread_barrier_wait (&b);
  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
    {
      puts ("barrier_wait failed");
      exit (1);
    }

  if (pthread_mutex_lock (&m) != 0)
    {
      puts ("mutex_lock failed");
      exit (1);
    }

  /* Send the thread a signal which it doesn't catch and which will
     cause the process to terminate.  */
  if (pthread_kill (th, SIGUSR1) != 0)
    {
      puts ("kill failed");
      exit (1);
    }

  /* This call should never return.  */
  pthread_join (th, NULL);

  return 0;
}

Here is the call graph for this function:

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

Definition at line 31 of file tst-kill1.c.

{
  if (pthread_mutex_lock (&m) != 0)
    {
      puts ("child: mutex_lock failed");
      exit (1);
    }

  int e = pthread_barrier_wait (&b);
  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
    {
      puts ("child: barrier_wait failed");
      exit (1);
    }

  /* This call should never return.  */
  pthread_cond_wait (&c, &m);

  return NULL;
}

Here is the call graph for this function:


Variable Documentation

pthread_barrier_t b [static]

Definition at line 28 of file tst-kill1.c.

Definition at line 26 of file tst-kill1.c.

Definition at line 27 of file tst-kill1.c.