* lib/waitpid.c: New file, extracted from lib/sys_wait.in.h.
* lib/sys_wait.in.h: Include <sys/types.h>, c++defs.h, warn-on-use.h.
Don't include <process.h>.
(waitpid): Declare only, using modern idiom.
* m4/waitpid.m4: New file.
* m4/sys_wait_h.m4 (gl_SYS_WAIT_H): Check whether waitpid is declared.
* modules/waitpid: New file.
* modules/sys_wait (Depends-on): Add c++defs, warn-on-use, waitpid.
(Makefile.am): Update.
Reported by Tatsuro MATSUOKA <tmacchant5@yahoo.co.jp>.
+2010-09-29 Bruno Haible <bruno@clisp.org>
+
+ New module 'waitpid'.
+ * lib/waitpid.c: New file, extracted from lib/sys_wait.in.h.
+ * lib/sys_wait.in.h: Include <sys/types.h>, c++defs.h, warn-on-use.h.
+ Don't include <process.h>.
+ (waitpid): Declare only, using modern idiom.
+ * m4/waitpid.m4: New file.
+ * m4/sys_wait_h.m4 (gl_SYS_WAIT_H): Check whether waitpid is declared.
+ * modules/waitpid: New file.
+ * modules/sys_wait (Depends-on): Add c++defs, warn-on-use, waitpid.
+ (Makefile.am): Update.
+ Reported by Tatsuro MATSUOKA <tmacchant5@yahoo.co.jp>.
+
2010-09-28 Bruno Haible <bruno@clisp.org>
poll: Assume ANSI C.
#ifndef _GL_SYS_WAIT_H
#define _GL_SYS_WAIT_H
+/* Get pid_t. */
+#include <sys/types.h>
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
/* Unix API. */
# define WCOREDUMP(x) ((x) & 0x80)
# endif
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-/* Declarations of functions. */
-
-# ifdef __cplusplus
-}
-# endif
-
#else
/* Native Windows API. */
-# include <process.h> /* for _cwait, WAIT_CHILD */
# include <signal.h> /* for SIGTERM */
-# define waitpid(pid,statusp,options) _cwait (statusp, pid, WAIT_CHILD)
-
/* The following macros apply to an argument x, that is a status of a process,
as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess().
This value is simply an 'int', not composed of bit fields. */
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Declarations of functions. */
+
+#if 1 /* @GNULIB_WAITPID@ */
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+_GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
+# endif
+_GL_CXXALIAS_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
+_GL_CXXALIASWARN (waitpid);
+#elif defined GNULIB_POSIXCHECK
+# undef waitpid
+# if HAVE_RAW_DECL_WAITPID
+_GL_WARN_ON_USE (waitpid, "waitpid is unportable - "
+ "use gnulib module sys_wait for portability");
+# endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _GL_SYS_WAIT_H */
#endif /* _GL_SYS_WAIT_H */
--- /dev/null
+/* Wait for process state change.
+ Copyright (C) 2001-2003, 2005-2010 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include <sys/wait.h>
+
+/* Implementation for native Win32 systems. */
+
+#include <process.h> /* for _cwait, WAIT_CHILD */
+
+pid_t
+waitpid (pid_t pid, int *statusp, int options)
+{
+ return _cwait (statusp, pid, WAIT_CHILD);
+}
-# sys_wait_h.m4 serial 4
+# sys_wait_h.m4 serial 5
dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl <sys/wait.h> is always overridden, because of GNULIB_POSIXCHECK.
gl_CHECK_NEXT_HEADERS([sys/wait.h])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[#include <sys/wait.h>]],
+ [waitpid])
])
AC_DEFUN([gl_SYS_WAIT_MODULE_INDICATOR],
--- /dev/null
+# waitpid.m4 serial 1
+dnl Copyright (C) 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_WAITPID],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ case $host_os in
+ mingw*)
+ AC_LIBOBJ([waitpid])
+ ;;
+ esac
+])
m4/sys_wait_h.m4
Depends-on:
+c++defs
include_next
+warn-on-use
+waitpid
configure.ac:
gl_SYS_WAIT_H
# We need the following in order to create <sys/wait.h> when the system
# has one that is incomplete.
-sys/wait.h: sys_wait.in.h
+sys/wait.h: sys_wait.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''NEXT_SYS_WAIT_H''@|$(NEXT_SYS_WAIT_H)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/sys_wait.in.h; \
} > $@-t && \
mv $@-t $@
--- /dev/null
+Description:
+waitpid() function: wait for process state change
+
+Files:
+lib/waitpid.c
+m4/waitpid.m4
+
+Depends-on:
+sys_wait
+
+configure.ac:
+gl_FUNC_WAITPID
+
+Makefile.am:
+
+Include:
+<sys/wait.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible