return pid;
}
-int
-__gnat_waitpid (int pid)
-{
- int status = 0;
-
-#if defined (_WIN32)
- cwait (&status, pid, _WAIT_CHILD);
-#elif defined (__EMX__) || defined (MSDOS) || defined (__vxworks)
- /* Status is already zero, so nothing to do. */
-#else
- waitpid (pid, &status, 0);
- status = WEXITSTATUS (status);
-#endif
-
- return status;
-}
-
void
__gnat_os_exit (int status)
{
extern int __gnat_portable_spawn (char *[]);
extern int __gnat_portable_no_block_spawn (char *[]);
extern int __gnat_portable_wait (int *);
-extern int __gnat_waitpid (int);
extern char *__gnat_locate_exec (char *, char *);
extern char *__gnat_locate_exec_on_path (char *);
extern char *__gnat_locate_regular_file (char *, char *);
#include "system.h"
#endif
+#include <sys/types.h>
+
+#ifdef __MINGW32__
+#if OLD_MINGW
+#include <sys/wait.h>
+#endif
+#else
+#include <sys/wait.h>
+#endif
+
/* This file provides the low level functionalities needed to implement Expect
capabilities in GNAT.Expect.
Implementations for unix and windows systems is provided.
{
process_handle = OpenProcess (PROCESS_TERMINATE, FALSE, pid);
if (process_handle != NULL)
- TerminateProcess (process_handle, 0);
+ {
+ TerminateProcess (process_handle, 0);
+ CloseHandle (process_handle);
+ }
}
}
int
+__gnat_waitpid (int pid)
+{
+ HANDLE process_handle;
+ DWORD exitcode = 1;
+ DWORD res;
+
+ process_handle = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid);
+
+ if (process_handle != NULL)
+ {
+ res = WaitForSingleObject (process_handle, INFINITE);
+ GetExitCodeProcess (process_handle, &exitcode);
+ CloseHandle (process_handle);
+ }
+
+ return (int) exitcode;
+}
+
+int
__gnat_expect_fork (void)
{
return 0;
#include <vms/iodef.h>
int
+__gnat_waitpid (int pid)
+{
+ int status = 0;
+
+ waitpid (pid, &status, 0);
+ status = WEXITSTATUS (status);
+
+ return status;
+}
+
+int
__gnat_pipe (int *fd)
{
return pipe (fd);
}
int
+__gnat_waitpid (int pid)
+{
+ int status = 0;
+
+ waitpid (pid, &status, 0);
+ status = WEXITSTATUS (status);
+
+ return status;
+}
+
+int
__gnat_pipe (int *fd)
{
return pipe (fd);
}
int
+__gnat_waitpid (int pid, int sig)
+{
+ return 0;
+}
+
+int
__gnat_pipe (int *fd)
{
return -1;