OSDN Git Service

* times.cc (hires::prime): Restore thread priority on failure condition.
[pf3gnuchains/pf3gnuchains3x.git] / winsup / cygwin / cygrun.c
1 /* cygrun.c: testsuite support program
2
3    Copyright 1999, 2000, 2001 Red Hat, Inc.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 /* This program is intended to be used only by the testsuite.  It runs
12    programs without using the cygwin api, so that the just-built dll
13    can be tested without interference from the currently installed
14    dll. */
15
16 #include <stdio.h>
17 #include <windows.h>
18 #include <stdlib.h>
19
20 int
21 main(int argc, char **argv)
22 {
23   STARTUPINFO sa;
24   PROCESS_INFORMATION pi;
25   DWORD ec = 1;
26
27   if (argc < 2)
28     {
29       fprintf(stderr, "Usage: cygrun [program]\n");
30       exit (0);
31     }
32
33   putenv("CYGWIN_TESTING=1");
34   SetEnvironmentVariable("CYGWIN_TESTING", "1");
35
36   memset(&sa, 0, sizeof(sa));
37   memset(&pi, 0, sizeof(pi));
38   if (!CreateProcess(0, argv[1], 0, 0, 1, 0, 0, 0, &sa, &pi))
39     {
40       fprintf(stderr, "CreateProcess %s failed\n", argv[1]);
41       exit(1);
42     }
43
44   WaitForSingleObject(pi.hProcess, INFINITE);
45
46   GetExitCodeProcess(pi.hProcess, &ec);
47
48   CloseHandle(pi.hProcess);
49   CloseHandle(pi.hThread);
50   return ec;
51 }