bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

execute, spawn-pipe: Use _spawnvpe, not spawnvpe


From: Bruno Haible
Subject: execute, spawn-pipe: Use _spawnvpe, not spawnvpe
Date: Tue, 11 Aug 2020 20:56:49 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

> With clang, on native Windows, the function 'chsize' is not present any more.
> This matches the deprecation of this spelling by Microsoft
> <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-chsize>.

Similarly for 'spawnvpe'. It's called '_spawnvpe' now. The old name is
deprecated:
<https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/spawnvpe>


2020-08-11  Bruno Haible  <bruno@clisp.org>

        execute, spawn-pipe: Use _spawnvpe, not spawnvpe.
        * lib/execute.c (execute): Use _spawnvpe, not spawnvpe.
        * lib/spawn-pipe.c (create_pipe): Likewise.
        * tests/test-nonblocking-pipe-main.c (main): Likewise.
        * tests/test-nonblocking-socket-main.c (main): Likewise.
        * lib/wait-process.c: Update comment.
        * doc/posix-functions/fork.texi: Update.

diff --git a/doc/posix-functions/fork.texi b/doc/posix-functions/fork.texi
index bfbc6e2..cae51d1 100644
--- a/doc/posix-functions/fork.texi
+++ b/doc/posix-functions/fork.texi
@@ -23,5 +23,5 @@ call.  @code{vfork} is a variant of @code{fork} that has been 
introduced to
 optimize the @code{fork}/@code{exec} pattern.
 @item
 On Windows platforms (excluding Cygwin), this function is not implemented; use
-@code{spawnvp} instead.
+@code{_spawnvp} instead.
 @end itemize
diff --git a/lib/execute.c b/lib/execute.c
index 686fb7e..15d9ba9 100644
--- a/lib/execute.c
+++ b/lib/execute.c
@@ -141,25 +141,25 @@ execute (const char *progname,
               && ((null_stdout && nulloutfd == STDOUT_FILENO)
                   || (null_stderr && nulloutfd == STDERR_FILENO)
                   || close (nulloutfd) >= 0))))
-    /* Use spawnvpe and pass the environment explicitly.  This is needed if
+    /* Use _spawnvpe and pass the environment explicitly.  This is needed if
        the program has modified the environment using putenv() or [un]setenv().
        On Windows, programs have two environments, one in the "environment
        block" of the process and managed through SetEnvironmentVariable(), and
        one inside the process, in the location retrieved by the 'environ'
-       macro.  When using spawnvp() without 'e', the child process inherits a
+       macro.  When using _spawnvp() without 'e', the child process inherits a
        copy of the environment block - ignoring the effects of putenv() and
        [un]setenv().  */
     {
-      exitcode = spawnvpe (P_WAIT, prog_path, (const char **) prog_argv,
-                           (const char **) environ);
+      exitcode = _spawnvpe (P_WAIT, prog_path, (const char **) prog_argv,
+                            (const char **) environ);
       if (exitcode < 0 && errno == ENOEXEC)
         {
           /* prog is not a native executable.  Try to execute it as a
              shell script.  Note that prepare_spawn() has already prepended
              a hidden element "sh.exe" to prog_argv.  */
           --prog_argv;
-          exitcode = spawnvpe (P_WAIT, prog_argv[0], (const char **) prog_argv,
-                               (const char **) environ);
+          exitcode = _spawnvpe (P_WAIT, prog_argv[0], (const char **) 
prog_argv,
+                                (const char **) environ);
         }
     }
   if (nulloutfd >= 0)
diff --git a/lib/spawn-pipe.c b/lib/spawn-pipe.c
index b1c0762..947825a 100644
--- a/lib/spawn-pipe.c
+++ b/lib/spawn-pipe.c
@@ -118,7 +118,7 @@ create_pipe (const char *progname,
 #if (defined _WIN32 && ! defined __CYGWIN__) || defined __KLIBC__
 
   /* Native Windows API.
-     This uses _pipe(), dup2(), and spawnv().  It could also be implemented
+     This uses _pipe(), dup2(), and _spawnv().  It could also be implemented
      using the low-level functions CreatePipe(), DuplicateHandle(),
      CreateProcess() and _open_osfhandle(); see the GNU make and GNU clisp
      and cvs source code.  */
@@ -186,25 +186,25 @@ create_pipe (const char *progname,
     /* The child process doesn't inherit ifd[0], ifd[1], ofd[0], ofd[1],
        but it inherits all open()ed or dup2()ed file handles (which is what
        we want in the case of STD*_FILENO).  */
-    /* Use spawnvpe and pass the environment explicitly.  This is needed if
+    /* Use _spawnvpe and pass the environment explicitly.  This is needed if
        the program has modified the environment using putenv() or [un]setenv().
        On Windows, programs have two environments, one in the "environment
        block" of the process and managed through SetEnvironmentVariable(), and
        one inside the process, in the location retrieved by the 'environ'
-       macro.  When using spawnvp() without 'e', the child process inherits a
+       macro.  When using _spawnvp() without 'e', the child process inherits a
        copy of the environment block - ignoring the effects of putenv() and
        [un]setenv().  */
     {
-      child = spawnvpe (P_NOWAIT, prog_path, (const char **) prog_argv,
-                        (const char **) environ);
+      child = _spawnvpe (P_NOWAIT, prog_path, (const char **) prog_argv,
+                         (const char **) environ);
       if (child < 0 && errno == ENOEXEC)
         {
           /* prog is not a native executable.  Try to execute it as a
              shell script.  Note that prepare_spawn() has already prepended
              a hidden element "sh.exe" to prog_argv.  */
           --prog_argv;
-          child = spawnvpe (P_NOWAIT, prog_argv[0], (const char **) prog_argv,
-                            (const char **) environ);
+          child = _spawnvpe (P_NOWAIT, prog_argv[0], (const char **) prog_argv,
+                             (const char **) environ);
         }
     }
   if (child == -1)
diff --git a/lib/wait-process.c b/lib/wait-process.c
index 58a1e11..dd9ea1e 100644
--- a/lib/wait-process.c
+++ b/lib/wait-process.c
@@ -44,7 +44,7 @@
 # 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)
 
diff --git a/tests/test-nonblocking-pipe-main.c 
b/tests/test-nonblocking-pipe-main.c
index e72a9aa..0e132f0 100644
--- a/tests/test-nonblocking-pipe-main.c
+++ b/tests/test-nonblocking-pipe-main.c
@@ -82,8 +82,8 @@ main (int argc, char *argv[])
     child_argv[2] = NULL;
 
 #if defined _WIN32 && ! defined __CYGWIN__
-    child = spawnvpe (P_NOWAIT, child_path, child_argv,
-                      (const char **) environ);
+    child = _spawnvpe (P_NOWAIT, child_path, child_argv,
+                       (const char **) environ);
     ASSERT (child >= 0);
 #else
     {
diff --git a/tests/test-nonblocking-socket-main.c 
b/tests/test-nonblocking-socket-main.c
index c0f885a..500479d 100644
--- a/tests/test-nonblocking-socket-main.c
+++ b/tests/test-nonblocking-socket-main.c
@@ -69,8 +69,8 @@ main (int argc, char *argv[])
     child_argv[3] = NULL;
 
 #if defined _WIN32 && ! defined __CYGWIN__
-    child = spawnvpe (P_NOWAIT, child_path, child_argv,
-                      (const char **) environ);
+    child = _spawnvpe (P_NOWAIT, child_path, child_argv,
+                       (const char **) environ);
     ASSERT (child >= 0);
 #else
     {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]