-/* Test of posix_spawn() function.
- Copyright (C) 2008-2016 Free Software Foundation, Inc.
+/* Test of posix_spawn() function: writing to a subprocess.
+ Copyright (C) 2008-2021 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
#include <sys/types.h>
#include <sys/wait.h>
-extern char **environ;
-
-#define CHILD_PROGRAM_FILENAME "test-posix_spawn2.sh"
+#define CHILD_PROGRAM_FILENAME "test-posix_spawn-dup2-stdin.sh"
static int
fd_safer (int fd)
int
main ()
{
- char *argv[3] = { (char *) "/bin/sh", (char *) CHILD_PROGRAM_FILENAME, NULL };
+ char *argv[3] = { (char *) BOURNE_SHELL, (char *) CHILD_PROGRAM_FILENAME, NULL };
int ofd[2];
sigset_t blocked_signals;
sigset_t fatal_signal_set;
sigemptyset (&fatal_signal_set);
sigaddset (&fatal_signal_set, SIGINT);
sigaddset (&fatal_signal_set, SIGTERM);
+ #ifdef SIGHUP
sigaddset (&fatal_signal_set, SIGHUP);
+ #endif
+ #ifdef SIGPIPE
sigaddset (&fatal_signal_set, SIGPIPE);
+ #endif
sigprocmask (SIG_BLOCK, &fatal_signal_set, NULL);
actions_allocated = false;
attrs_allocated = false;
|| (err = posix_spawn_file_actions_addclose (&actions, ofd[1])) != 0
|| (err = posix_spawnattr_init (&attrs)) != 0
|| (attrs_allocated = true,
+ #if defined _WIN32 && !defined __CYGWIN__
+ 0
+ #else
(err = posix_spawnattr_setsigmask (&attrs, &blocked_signals)) != 0
- || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0)
- || (err = posix_spawnp (&child, "/bin/sh", &actions, &attrs, argv, environ)) != 0))
+ || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0
+ #endif
+ )
+ || (err = posix_spawnp (&child, BOURNE_SHELL, &actions, &attrs, argv, environ)) != 0))
{
if (actions_allocated)
posix_spawn_file_actions_destroy (&actions);