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
62
63
64
65
66
67
|
/* cygrun.c: testsuite support program
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
/* This program is intended to be used only by the testsuite. It runs
programs without using the cygwin api, so that the just-built dll
can be tested without interference from the currently installed
dll. */
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
int
main (int argc, char **argv)
{
STARTUPINFO sa;
PROCESS_INFORMATION pi;
DWORD ec = 1;
char *p;
if (argc < 2)
{
fprintf (stderr, "Usage: cygrun [program]\n");
exit (0);
}
SetEnvironmentVariable ("CYGWIN_TESTING", "1");
if ((p = getenv ("CYGWIN")) == NULL || (strstr (p, "ntsec") == NULL))
{
char buf[4096];
if (!p)
{
p = buf;
p[0] = '\0';
}
else
{
strcpy (buf, p);
strcat (buf, " ");
}
strcat(buf, "ntsec");
SetEnvironmentVariable ("CYGWIN", buf);
}
memset (&sa, 0, sizeof (sa));
memset (&pi, 0, sizeof (pi));
if (!CreateProcess (0, argv[1], 0, 0, 1, 0, 0, 0, &sa, &pi))
{
fprintf (stderr, "CreateProcess %s failed\n", argv[1]);
exit (1);
}
WaitForSingleObject (pi.hProcess, INFINITE);
GetExitCodeProcess (pi.hProcess, &ec);
CloseHandle (pi.hProcess);
CloseHandle (pi.hThread);
if (ec > 0xff)
ec >>= 8;
return ec;
}
|