Back to index

glibc  2.9
Defines | Functions | Variables
tst-cancel3.c File Reference
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include "../test-skeleton.c"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

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

Variables

static int fd [2]

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 97 of file tst-cancel3.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 45 of file tst-cancel3.c.

{
  pthread_t th;
  void *r;
  struct sigaction sa;

  sa.sa_handler = SIG_IGN;
  sigemptyset (&sa.sa_mask);
  sa.sa_flags = 0;

  if (sigaction (SIGPIPE, &sa, NULL) != 0)
    {
      puts ("sigaction failed");
      return 1;
    }

  if (pipe (fd) != 0)
    {
      puts ("pipe failed");
      return 1;
    }

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

  if (pthread_cancel (th) != 0)
    {
      puts ("cancel failed");
      return 1;
    }

  /* This will cause the read in the child to return.  */
  close (fd[0]);

  if (pthread_join (th, &r) != 0)
    {
      puts ("join failed");
      return 1;
    }

  if (r != PTHREAD_CANCELED)
    {
      puts ("result is wrong");
      return 1;
    }

  return 0;
}

Here is the call graph for this function:

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

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

{
  char buf[100];

  if (read (fd[0], buf, sizeof (buf)) == sizeof (buf))
    {
      puts ("read succeeded");
      return (void *) 1l;
    }

  return NULL;
}

Here is the call graph for this function:


Variable Documentation

int fd[2] [static]

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