Back to index

glibc  2.9
Defines | Functions | Variables
tst-popen2.c File Reference
#include <errno.h>
#include <error.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "../test-skeleton.c"

Go to the source code of this file.


#define TEST_FUNCTION   do_test ()


static void * dummy (void *x)
static int do_test (void)


static char buf [sizeof"something\n"]

Define Documentation

#define TEST_FUNCTION   do_test ()

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

Function Documentation

static int do_test ( void  ) [static]

Definition at line 18 of file tst-popen2.c.

  FILE *f;
  pthread_t p;
  int err;

  f = popen ("echo something", "r");
  if (f == NULL)
    error (EXIT_FAILURE, errno, "popen failed");
  if (fgets (buf, sizeof (buf), f) == NULL)
    error (EXIT_FAILURE, 0, "fgets failed");
  if (strcmp (buf, "something\n"))
    error (EXIT_FAILURE, 0, "read wrong data");
  if (pclose (f))
    error (EXIT_FAILURE, errno, "pclose returned non-zero");
  if ((err = pthread_create (&p, NULL, dummy, NULL)))
    error (EXIT_FAILURE, err, "pthread_create failed");
  if ((err = pthread_join (p, NULL)))
    error (EXIT_FAILURE, err, "pthread_join failed");
  exit (0);

Here is the call graph for this function:

static void* dummy ( void *  x) [static]

Definition at line 10 of file tst-popen2.c.

  return NULL;

Variable Documentation

char buf[sizeof"something\n"] [static]

Definition at line 15 of file tst-popen2.c.