changeset 11269:8fea875fffee

Avoid errors from posix_spawn on platforms where it is not yet ported to.
author Bruno Haible <bruno@clisp.org>
date Fri, 06 Mar 2009 15:39:33 +0100
parents 16ae9ebb84d9
children e70e12db795d
files ChangeLog lib/spawni.c modules/posix_spawn-tests modules/posix_spawnp-tests
diffstat 4 files changed, 50 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-03-06  Eric Blake  <ebb9@byu.net>
+            Bruno Haible  <bruno@clisp.org>
+
+	* lib/spawni.c (__spawni) [WIN32_NATIVE]: Define as a stub.
+	* modules/posix_spawn-tests (configure.ac): Define POSIX_SPAWN_PORTED
+	condition.
+	(Makefile.am): Do nothing if POSIX_SPAWN_PORTED is false.
+	* modules/posix_spawnp-tests (configure.ac): Define POSIX_SPAWN_PORTED
+	condition.
+	(Makefile.am): Do nothing if POSIX_SPAWN_PORTED is false.
+
 2009-03-06  Eric Blake  <ebb9@byu.net>
 
 	* lib/execute.c (execute) [WIN32_NATIVE]: Cast arguments of spawnvpe,
--- a/lib/spawni.c
+++ b/lib/spawni.c
@@ -1,5 +1,5 @@
 /* Guts of POSIX spawn interface.  Generic POSIX.1 version.
-   Copyright (C) 2000-2005, 2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2000-2006, 2008-2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software: you can redistribute it and/or modify
@@ -89,6 +89,22 @@
 #define SPAWN_ERROR	127
 
 
+#if defined _MSC_VER || defined __MINGW32__
+
+/* Native Woe32 API.  */
+int
+__spawni (pid_t *pid, const char *file,
+	  const posix_spawn_file_actions_t *file_actions,
+	  const posix_spawnattr_t *attrp, char *const argv[],
+	  char *const envp[], int use_path)
+{
+  /* Not yet implemented.  */
+  return ENOSYS;
+}
+
+#else
+
+
 /* The file is accessible but it is not an executable file.  Invoke
    the shell to interpret it as a script.  */
 static void
@@ -354,3 +370,5 @@
   /* Return with an error.  */
   _exit (SPAWN_ERROR);
 }
+
+#endif
--- a/modules/posix_spawn-tests
+++ b/modules/posix_spawn-tests
@@ -10,7 +10,17 @@
 sys_wait
 
 configure.ac:
+AC_EGREP_CPP([notposix], [[
+#if defined _MSC_VER || defined __MINGW32__
+  notposix
+#endif
+  ]],
+  [posix_spawn_ported=no],
+  [posix_spawn_ported=yes])
+AM_CONDITIONAL([POSIX_SPAWN_PORTED], [test $posix_spawn_ported = yes])
 
 Makefile.am:
+if POSIX_SPAWN_PORTED
 TESTS += test-posix_spawn3
 check_PROGRAMS += test-posix_spawn3
+endif
--- a/modules/posix_spawnp-tests
+++ b/modules/posix_spawnp-tests
@@ -20,8 +20,17 @@
 sys_wait
 
 configure.ac:
+AC_EGREP_CPP([notposix], [[
+#if defined _MSC_VER || defined __MINGW32__
+  notposix
+#endif
+  ]],
+  [posix_spawn_ported=no],
+  [posix_spawn_ported=yes])
+AM_CONDITIONAL([POSIX_SPAWN_PORTED], [test $posix_spawn_ported = yes])
 
 Makefile.am:
+if POSIX_SPAWN_PORTED
 TESTS += test-posix_spawn1 test-posix_spawn2
 check_PROGRAMS += test-posix_spawn1 test-posix_spawn2
 
@@ -36,3 +45,4 @@
 	cp $(srcdir)/test-posix_spawn2.in.sh $@-t
 	mv $@-t $@
 MOSTLYCLEANFILES += test-posix_spawn2.sh test-posix_spawn2.sh-t
+endif