2 Copyright (C) 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
34 execl (_PATH_BSHELL, _PATH_BSHELL, "-c", "echo $$", NULL);
36 puts ("execl failed");
51 /* Not interested in knowing when the pipe is closed. */
52 if (sigignore (SIGPIPE) != 0)
54 puts ("sigignore failed");
67 /* Use the fd for stdout. This is kind of ugly because it
68 substitutes the fd of stdout but we know what we are doing
70 if (dup2 (fd[1], STDOUT_FILENO) != STDOUT_FILENO)
79 if (pthread_create (&th, NULL, tf, NULL) != 0)
81 puts ("create failed");
85 if (pthread_join (th, NULL) == 0)
87 puts ("join succeeded!?");
91 puts ("join returned!?");
99 bool seen_pid = false;
100 while (TEMP_FAILURE_RETRY ((n = read (fd[0], buf, sizeof (buf)))) > 0)
102 /* We only expect to read the PID. */
104 long int rpid = strtol (buf, &endp, 10);
108 printf ("didn't parse whole line: \"%s\"\n", buf);
113 puts ("read empty line");
119 printf ("found \"%s\", expected PID %ld\n", buf, (long int) pid);
125 puts ("found more than one PID line");
134 int err = waitpid (pid, &status, 0);
137 puts ("waitpid failed");
143 puts ("didn't get PID");
150 #define TEST_FUNCTION do_test ()
151 #include "../test-skeleton.c"