* [Ada] Spawning processes with no PATH
@ 2015-10-26 11:37 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2015-10-26 11:37 UTC (permalink / raw)
To: gcc-patches; +Cc: Bob Duff
[-- Attachment #1: Type: text/plain, Size: 889 bytes --]
This patch fixes a bug in which GNAT.Expect.Non_Blocking_Spawn fails to find an
executable when the PATH environment variable is not set. The executable
should be found if it contains a directory name.
The following test should execute quietly.
gnatmake -q do_nothing.adb
gnatmake -q spawn.adb
unset PATH
./spawn
procedure Do_Nothing is
begin
null;
end Do_Nothing;
with GNAT.Expect;
with GNAT.OS_Lib;
Procedure Spawn is
P : GNAT.Expect.Process_Descriptor;
T : constant GNAT.Os_Lib.Argument_List(1..0) := ( others => null);
begin
GNAT.Expect.Non_Blocking_Spawn(P, "./do_nothing", T);
end Spawn;
Tested on x86_64-pc-linux-gnu, committed on trunk
2015-10-26 Bob Duff <duff@adacore.com>
* adaint.c (__gnat_locate_exec_on_path): If the PATH environment
variable is not set, do not return NULL, because we can still find
the executable if it includes a directory name.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 811 bytes --]
Index: adaint.c
===================================================================
--- adaint.c (revision 229320)
+++ adaint.c (working copy)
@@ -2787,16 +2787,19 @@
apath_val = (char *) alloca (EXPAND_BUFFER_SIZE);
WS2SC (apath_val, wapath_val, EXPAND_BUFFER_SIZE);
- return __gnat_locate_exec (exec_name, apath_val);
#else
char *path_val = getenv ("PATH");
- if (path_val == NULL) return NULL;
+ /* If PATH is not defined, proceed with __gnat_locate_exec anyway, so we can
+ find files that contain directory names. */
+
+ if (path_val == NULL) path_val = "";
apath_val = (char *) alloca (strlen (path_val) + 1);
strcpy (apath_val, path_val);
+#endif
+
return __gnat_locate_exec (exec_name, apath_val);
-#endif
}
/* Dummy functions for Osint import for non-VMS systems.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-10-26 11:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 11:37 [Ada] Spawning processes with no PATH Arnaud Charlet
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).