public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sbellon at sbellon dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/20075] Bug in GNAT.Expect.Non_Blocking_Spawn
Date: Mon, 28 Feb 2005 02:52:00 -0000	[thread overview]
Message-ID: <20050227184715.12642.qmail@sourceware.org> (raw)
In-Reply-To: <20050219113933.20075.sbellon@sbellon.de>


------- Additional Comments From sbellon at sbellon dot de  2005-02-27 18:47 -------
I have investigated further. There are further places in the C part of the GNAT
library that need changing because they are inconsistent.

In __gnat_portable_spawn in ada/adaint.c the spawn/exec calls are always the
'path' variants except for Unix. The patch for GCC 3.4.3 should be as follows:

--- adaint.c    2004-01-13 12:51:31.000000000 +0100
+++ patched/adaint.c    2005-02-25 13:25:40.000000000 +0100
@@ -1520,9 +1520,9 @@
   if (pid == 0)
     {
       /* The child. */
-      if (execv (args[0], args) != 0)
+      if (execvp (args[0], args) != 0)
 #if defined (VMS)
-       return -1; /* execv is in parent context on VMS.  */
+       return -1; /* execvp is in parent context on VMS.  */
 #else
        _exit (1);
 #endif

The only excuse could be that not all operating systems support execvp. In that
case, a simple define could fix that situation.

Furthermore, in ada/expect.c there are several versions of
__gnat_expect_portable_execvp that in fact don't call the 'path' variant of the
spawn/exec call although the function is called __gnat_expect_portable_execvp.
The following patch fixes that:

--- expect.c    2003-10-31 02:08:42.000000000 +0100
+++ patched/expect.c    2005-02-25 13:31:57.000000000 +0100
@@ -80,7 +80,7 @@
 void
 __gnat_expect_portable_execvp (int *pid, char *cmd, char *argv[])
 {
-  *pid = (int) spawnve (_P_NOWAIT, cmd, argv, NULL);
+  *pid = _spawnvp (_P_NOWAIT, cmd, argv);
 }
 
 int
@@ -168,8 +168,7 @@
 __gnat_expect_portable_execvp (int *pid, char *cmd, char *argv[])
 {
   *pid = (int) getpid ();
-  /* Since cmd is fully qualified, it is incorrect to call execvp */
-  execv (cmd, argv);
+  execvp (cmd, argv);
   _exit (1);
 }
 
@@ -308,8 +307,7 @@
 __gnat_expect_portable_execvp (int *pid, char *cmd, char *argv[])
 {
   *pid = (int) getpid ();
-  /* Since cmd is fully qualified, it is incorrect to call execvp */
-  execv (cmd, argv);
+  execvp (cmd, argv);
   _exit (1);
 }
 

The comment that it is incorrect to call execvp is in fact incorrect itself. The
specification of execvp allows to call it with a fully qualified pathname and in
fact does exactly what is needed here.

With all my suggested patches applied, the handling of spawning child processes
and the way the command itself is passed to the child process are made consistent.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20075


  parent reply	other threads:[~2005-02-27 18:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-19 18:27 [Bug ada/20075] New: " sbellon at sbellon dot de
2005-02-20 23:07 ` [Bug ada/20075] " ludovic dot brenta at insalien dot org
2005-02-21  2:01 ` sbellon at sbellon dot de
2005-02-28  2:52 ` sbellon at sbellon dot de [this message]
2005-09-01 11:45 ` charlet at gcc dot gnu dot org
2005-09-01 11:47 ` charlet at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050227184715.12642.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).