Update.
[glibc.git] / linuxthreads / tst-popen2.c
blob3ff69acd5249eecb764d47cea155784b0ed47ecf
1 #include <errno.h>
2 #include <error.h>
3 #include <pthread.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
9 static void *
10 dummy (void *x)
12 return NULL;
15 static char buf[sizeof "something\n"];
17 static int
18 do_test (void)
20 FILE *f;
21 pthread_t p;
22 int err;
24 f = popen ("echo something", "r");
25 if (f == NULL)
26 error (EXIT_FAILURE, errno, "popen failed");
27 if (fgets (buf, sizeof (buf), f) == NULL)
28 error (EXIT_FAILURE, 0, "fgets failed");
29 if (strcmp (buf, "something\n"))
30 error (EXIT_FAILURE, 0, "read wrong data");
31 if (pclose (f))
32 error (EXIT_FAILURE, errno, "pclose returned non-zero");
33 if ((err = pthread_create (&p, NULL, dummy, NULL)))
34 error (EXIT_FAILURE, err, "pthread_create failed");
35 if ((err = pthread_join (p, NULL)))
36 error (EXIT_FAILURE, err, "pthread_join failed");
37 exit (0);
40 #define TEST_FUNCTION do_test ()
41 #include "../test-skeleton.c"