/* Waiting for a subprocess to finish.
- Copyright (C) 2001-2003, 2005-2013 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2021 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software: you can redistribute it and/or modify
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/>. */
#include <config.h>
#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-#if defined _MSC_VER || defined __MINGW32__
+#if defined _WIN32 && ! defined __CYGWIN__
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
-/* The return value of spawnvp() is really a process handle as returned
+/* The return value of _spawnvp() is really a process handle as returned
by CreateProcess(). Therefore we can kill it using TerminateProcess. */
-#define kill(pid,sig) TerminateProcess ((HANDLE) (pid), sig)
+# define kill(pid,sig) TerminateProcess ((HANDLE) (pid), sig)
#endif
#endif
/* The cleanup action. It gets called asynchronously. */
-static void
+static _GL_ASYNC_SAFE void
cleanup_slaves (void)
{
for (;;)
}
}
+/* The cleanup action, taking a signal argument.
+ It gets called asynchronously. */
+static _GL_ASYNC_SAFE void
+cleanup_slaves_action (int sig _GL_UNUSED)
+{
+ cleanup_slaves ();
+}
+
/* Register a subprocess as being a slave process. This means that the
subprocess will be terminated when its creator receives a catchable fatal
signal or exits normally. Registration ends when wait_subprocess()
if (!cleanup_slaves_registered)
{
atexit (cleanup_slaves);
- at_fatal_signal (cleanup_slaves);
+ if (at_fatal_signal (cleanup_slaves_action) < 0)
+ xalloc_die ();
cleanup_slaves_registered = true;
}