Back to index

glibc  2.9
Defines | Functions
tst-cancel6.c File Reference
#include <pthread.h>
#include <stdio.h>
#include <stdlib.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)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 78 of file tst-cancel6.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 37 of file tst-cancel6.c.

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

  FILE *fp = fdopen (fd[0], "r");
  if (fp == NULL)
    {
      puts ("fdopen failed");
      return 1;
    }

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

  sleep (1);

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

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

  return r != PTHREAD_CANCELED;
}

Here is the call graph for this function:

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

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

{
  char buf[100];
  fgets (buf, sizeof (buf), arg);
  /* This call should never return.  */
  return NULL;
}

Here is the call graph for this function: