Back to index

glibc  2.9
Defines | Functions | Variables
tst-popen.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 36 of file tst-popen.c.

Function Documentation

static int do_test ( void  ) [static]

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

  FILE *f;
  pthread_t p;

  pthread_create (&p, NULL, dummy, NULL);
  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");
  exit (0);

Here is the call graph for this function:

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

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

  return NULL;

Variable Documentation

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

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