-
Notifications
You must be signed in to change notification settings - Fork 1
/
process.c
62 lines (45 loc) · 1.01 KB
/
process.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "global.h"
#if OS_WINDOWS
#include <windows.h>
#include <stdlib.h>
#include <errno.h>
#define WEXITSTATUS(status) (((status) &0xff00) >> 8)
#endif
/* LINUX ------------------------------------------------------------ */
#if OS_LINUX || OS_WINDOWS
S4 run_process (U1 *name)
{
S4 ret;
ret = system (name);
if (ret == -1)
{
perror ("run_shell:\n");
}
else
{
ret = WEXITSTATUS (ret);
}
return (ret);
}
#endif
/* WINDOWS ---------------------------------------------------------- */
/*
#if OS_WINDOWS
S8 run_process (U1 *name)
{
S4 ret;
LPDWORD *exit_code = NULL;
STARTUPINFO start_info;
PROCESS_INFORMATION process_info;
GetStartupInfo (&start_info);
ret = CreateProcess (NULL, name, NULL, NULL, FALSE, 0, NULL, NULL, &start_info, &process_info);
if (ret == 0)
{
return (-1);
}
WaitForSingleObject( process_info.hProcess, INFINITE );
GetExitCodeProcess(process_info.hProcess, exit_code);
return ((S8) exit_code);
}
#endif
*/