aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorPascal Obry <obry@adacore.com>2006-02-15 10:39:28 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2006-02-15 10:39:28 +0100
commit0273bbb409468d108c9f1c316c7d1e9f554c7275 (patch)
tree38f6bb932b194a9cf72a72ab305f4c9b4bbca977 /gcc/ada
parentd48e258e71954c337635c94cc21c8d046a7e1042 (diff)
downloadgcc-0273bbb409468d108c9f1c316c7d1e9f554c7275.zip
gcc-0273bbb409468d108c9f1c316c7d1e9f554c7275.tar.gz
gcc-0273bbb409468d108c9f1c316c7d1e9f554c7275.tar.bz2
expect.c (__gnat_expect_portable_execvp): New implementation.
2006-02-13 Pascal Obry <obry@adacore.com> * expect.c (__gnat_expect_portable_execvp): New implementation. The previous implementation was using the C runtime spawnve routine but the corresponding wait was using directly the Win32 API. This was causing some times a lock when waiting for an event using WaitForSingleObject in __gnat_waitpid. This new implementation uses the Win32 CreateProcess routine. Avoiding mixing C runtime and Win32 API fixes this problem. From-SVN: r111066
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/expect.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/gcc/ada/expect.c b/gcc/ada/expect.c
index dd03b1c..6d2cf86 100644
--- a/gcc/ada/expect.c
+++ b/gcc/ada/expect.c
@@ -114,7 +114,61 @@ __gnat_expect_fork (void)
void
__gnat_expect_portable_execvp (int *pid, char *cmd, char *argv[])
{
- *pid = (int) spawnve (_P_NOWAIT, cmd, argv, NULL);
+ BOOL result;
+ STARTUPINFO SI;
+ PROCESS_INFORMATION PI;
+ SECURITY_ATTRIBUTES SA;
+ int csize = 1;
+ char *full_command;
+ int k;
+
+ /* compute the total command line length. */
+ k = 0;
+ while (argv[k])
+ {
+ csize += strlen (argv[k]) + 1;
+ k++;
+ }
+
+ full_command = (char *) malloc (csize);
+ full_command[0] = '\0';
+
+ /* Startup info. */
+ SI.cb = sizeof (STARTUPINFO);
+ SI.lpReserved = NULL;
+ SI.lpReserved2 = NULL;
+ SI.lpDesktop = NULL;
+ SI.cbReserved2 = 0;
+ SI.lpTitle = NULL;
+ SI.dwFlags = 0;
+ SI.wShowWindow = SW_HIDE;
+
+ /* Security attributes. */
+ SA.nLength = sizeof (SECURITY_ATTRIBUTES);
+ SA.bInheritHandle = TRUE;
+ SA.lpSecurityDescriptor = NULL;
+
+ k = 0;
+ while (argv[k])
+ {
+ strcat (full_command, argv[k]);
+ strcat (full_command, " ");
+ k++;
+ }
+
+ result = CreateProcess
+ (NULL, (char *) full_command, &SA, NULL, TRUE,
+ GetPriorityClass (GetCurrentProcess()), NULL, NULL, &SI, &PI);
+
+ free (full_command);
+
+ if (result == TRUE)
+ {
+ CloseHandle (PI.hThread);
+ *pid = (int) PI.hProcess;
+ }
+ else
+ *pid = -1;
}
int