2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
29 #include <support/xsignal.h>
35 execl (_PATH_BSHELL
, _PATH_BSHELL
, "-c", "echo $$", NULL
);
37 puts ("execl failed");
52 /* Not interested in knowing when the pipe is closed. */
53 xsignal (SIGPIPE
, SIG_IGN
);
64 /* Use the fd for stdout. This is kind of ugly because it
65 substitutes the fd of stdout but we know what we are doing
67 if (dup2 (fd
[1], STDOUT_FILENO
) != STDOUT_FILENO
)
76 if (pthread_create (&th
, NULL
, tf
, NULL
) != 0)
78 puts ("create failed");
82 if (pthread_join (th
, NULL
) == 0)
84 puts ("join succeeded!?");
88 puts ("join returned!?");
96 bool seen_pid
= false;
97 while (TEMP_FAILURE_RETRY ((n
= read (fd
[0], buf
, sizeof (buf
)))) > 0)
99 /* We only expect to read the PID. */
101 long int rpid
= strtol (buf
, &endp
, 10);
105 printf ("didn't parse whole line: \"%s\"\n", buf
);
110 puts ("read empty line");
116 printf ("found \"%s\", expected PID %ld\n", buf
, (long int) pid
);
122 puts ("found more than one PID line");
131 int err
= waitpid (pid
, &status
, 0);
134 puts ("waitpid failed");
140 puts ("didn't get PID");
147 #define TEST_FUNCTION do_test ()
148 #include "../test-skeleton.c"