annotate tests/test-posix_spawn1.c @ 16616:2f2ef742aa4b

New module 'exp2'. * lib/math.in.h (exp2): New declaration. * lib/exp2.c: New file. * m4/exp2.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether exp2 is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_EXP2, HAVE_DECL_EXP2, REPLACE_EXP2. * modules/math (Makefile.am): Substitute GNULIB_EXP2, HAVE_DECL_EXP2, REPLACE_EXP2. * modules/exp2: New file. * tests/test-math-c++.cc: Check the declaration of exp2. * doc/posix-functions/exp2.texi: Mention the new module and the IRIX and OpenBSD problems.
author Bruno Haible <bruno@clisp.org>
date Wed, 07 Mar 2012 03:29:32 +0100
parents 8250f2777afc
children 91a203d21bbc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10547
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of posix_spawn() function.
16201
8250f2777afc maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents: 14079
diff changeset
2 Copyright (C) 2008-2012 Free Software Foundation, Inc.
10547
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2008. */
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <spawn.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
12489
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
23 #include "signature.h"
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
24 SIGNATURE_CHECK (posix_spawnp, int, (pid_t *, char const *,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
25 posix_spawn_file_actions_t const *,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
26 posix_spawnattr_t const *,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
27 char *const[], char *const[]));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
28 SIGNATURE_CHECK (posix_spawnattr_init, int, (posix_spawnattr_t *));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
29 SIGNATURE_CHECK (posix_spawnattr_destroy, int, (posix_spawnattr_t *));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
30 SIGNATURE_CHECK (posix_spawnattr_setsigmask, int, (posix_spawnattr_t *,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
31 sigset_t const *));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
32 SIGNATURE_CHECK (posix_spawnattr_setflags, int, (posix_spawnattr_t *, short));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
33 SIGNATURE_CHECK (posix_spawn_file_actions_init, int,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
34 (posix_spawn_file_actions_t *));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
35 SIGNATURE_CHECK (posix_spawn_file_actions_destroy, int,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
36 (posix_spawn_file_actions_t *));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
37 SIGNATURE_CHECK (posix_spawn_file_actions_addclose, int,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
38 (posix_spawn_file_actions_t *, int));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
39 SIGNATURE_CHECK (posix_spawn_file_actions_addopen, int,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
40 (posix_spawn_file_actions_t *, int, char const *, int,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
41 mode_t));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
42 SIGNATURE_CHECK (posix_spawn_file_actions_adddup2, int,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
43 (posix_spawn_file_actions_t *, int, int));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
44
10547
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 #include <errno.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 #include <fcntl.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 #include <signal.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 #include <stdbool.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 #include <stdio.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 #include <stdlib.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 #include <string.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 #include <unistd.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 #include <sys/types.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 #include <sys/wait.h>
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 extern char **environ;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 #define CHILD_PROGRAM_FILENAME "test-posix_spawn1.sh"
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 static int
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 fd_safer (int fd)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 if (0 <= fd && fd <= 2)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 int f = fd_safer (dup (fd));
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 int e = errno;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 close (fd);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 errno = e;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 fd = f;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 }
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 return fd;
10548
8a87d2aae670 Remove trailing spaces.
Bruno Haible <bruno@clisp.org>
parents: 10547
diff changeset
73 }
10547
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 int
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 main ()
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 char *argv[3] = { "/bin/sh", CHILD_PROGRAM_FILENAME, NULL };
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 int ifd[2];
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 sigset_t blocked_signals;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 sigset_t fatal_signal_set;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 posix_spawn_file_actions_t actions;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 bool actions_allocated;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 posix_spawnattr_t attrs;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 bool attrs_allocated;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 int err;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 pid_t child;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 int fd;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 FILE *fp;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 char line[80];
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 int status;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 int exitstatus;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 if (pipe (ifd) < 0 || (ifd[0] = fd_safer (ifd[0])) < 0)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 perror ("cannot create pipe");
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 exit (1);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 }
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 sigprocmask (SIG_SETMASK, NULL, &blocked_signals);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 sigemptyset (&fatal_signal_set);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 sigaddset (&fatal_signal_set, SIGINT);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 sigaddset (&fatal_signal_set, SIGTERM);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 sigaddset (&fatal_signal_set, SIGHUP);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 sigaddset (&fatal_signal_set, SIGPIPE);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 sigprocmask (SIG_BLOCK, &fatal_signal_set, NULL);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 actions_allocated = false;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 attrs_allocated = false;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 if ((err = posix_spawn_file_actions_init (&actions)) != 0
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 || (actions_allocated = true,
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 (err = posix_spawn_file_actions_adddup2 (&actions, ifd[1], STDOUT_FILENO)) != 0
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 || (err = posix_spawn_file_actions_addclose (&actions, ifd[1])) != 0
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 || (err = posix_spawn_file_actions_addclose (&actions, ifd[0])) != 0
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 || (err = posix_spawn_file_actions_addopen (&actions, STDIN_FILENO, "/dev/null", O_RDONLY, 0)) != 0
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 || (err = posix_spawnattr_init (&attrs)) != 0
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 || (attrs_allocated = true,
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 (err = posix_spawnattr_setsigmask (&attrs, &blocked_signals)) != 0
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 || (err = posix_spawnp (&child, "/bin/sh", &actions, &attrs, argv, environ)) != 0))
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 if (actions_allocated)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11049
diff changeset
121 posix_spawn_file_actions_destroy (&actions);
10547
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 if (attrs_allocated)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11049
diff changeset
123 posix_spawnattr_destroy (&attrs);
10547
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 errno = err;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 perror ("subprocess failed");
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 exit (1);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 }
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 posix_spawn_file_actions_destroy (&actions);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 posix_spawnattr_destroy (&attrs);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 close (ifd[1]);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 fd = ifd[0];
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 fp = fdopen (fd, "r");
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 if (fp == NULL)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 fprintf (stderr, "fdopen() failed\n");
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 exit (1);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 }
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 if (fread (line, 1, 80, fp) < 12)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 fprintf (stderr, "could not read expected output\n");
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 exit (1);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 }
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145 if (memcmp (line, "Halle Potta", 11) != 0)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 fprintf (stderr, "read output is not the expected output");
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 exit (1);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 }
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 fclose (fp);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 status = 0;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 while (waitpid (child, &status, 0) != child)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 ;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 if (!WIFEXITED (status))
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 exit (1);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 }
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 exitstatus = WEXITSTATUS (status);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 if (exitstatus != 0)
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 {
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 exit (1);
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 }
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 return 0;
f8cfd84a2220 A new test for posix_spawn.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166 }