|
Last change
on this file since 2137 was 2036, checked in by bird, 20 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
|
File size:
929 bytes
|
| Line | |
|---|
| 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>
|
|---|
| 8 |
|
|---|
| 9 | static void *
|
|---|
| 10 | dummy (void *x)
|
|---|
| 11 | {
|
|---|
| 12 | return NULL;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | static char buf[sizeof "something\n"];
|
|---|
| 16 |
|
|---|
| 17 | static int
|
|---|
| 18 | do_test (void)
|
|---|
| 19 | {
|
|---|
| 20 | FILE *f;
|
|---|
| 21 | pthread_t p;
|
|---|
| 22 | int err;
|
|---|
| 23 |
|
|---|
| 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);
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | #define TEST_FUNCTION do_test ()
|
|---|
| 41 | #include "../test-skeleton.c"
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.