Esempio n. 1
0
static void *
tf (void *arg)
{
  pthread_cleanup_push (cl, (void *) 4L);
  tf_body ();
  pthread_cleanup_pop (0);
  return NULL;
}
Esempio n. 2
0
static int
do_one_test (void)
{
  in_sh_body = 0;

  pid_t pid = fork ();

  if (pid == -1)
    {
      printf ("fork failed: %m\n");
      return 1;
    }

  if (pid)
    {
      int status;
      if (waitpid (pid, &status, 0) < 0)
	{
	  printf ("waitpid failed %m\n");
	  return 1;
	}

      return !WIFEXITED (status) || WEXITSTATUS (status);
    }

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

  cleanups = 0;
  if (pipe (fd) != 0 || pipe (fd + 2) != 0)
    {
      puts ("pipe failed");
      exit (1);
    }

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

  pthread_cleanup_push (cl, (void *) 4L);
  tf_body ();
  pthread_cleanup_pop (0);
  exit (1);
}