/[cvs]/joko/Uni/BSArch/03/win32/utils_proc.c
ViewVC logotype

Annotation of /joko/Uni/BSArch/03/win32/utils_proc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Thu Jun 15 23:09:44 2006 UTC (18 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.1: +9 -3 lines
File MIME type: text/plain
now processes multiple command from script file

1 joko 1.2 /* $Id: utils_proc.c,v 1.1 2006/06/15 22:58:58 joko Exp $ */
2 joko 1.1
3     #include <windows.h>
4    
5     BOOL os_start_process(char * filename, BOOL background) {
6    
7     STARTUPINFO si;
8     PROCESS_INFORMATION pi;
9 joko 1.2 BOOL proc_ok;
10 joko 1.1
11     //printf("start_process: '%s'\n", filename);
12    
13     // initialize structures
14     ZeroMemory(&si,sizeof(si));
15     si.cb = sizeof(STARTUPINFO);
16     ZeroMemory(&pi,sizeof(pi));
17    
18     // actually do something now...
19 joko 1.2 proc_ok = CreateProcess(
20 joko 1.1 NULL, filename,
21     NULL, NULL, FALSE, 0,
22     NULL, NULL,
23     &si,
24     &pi
25     );
26 joko 1.2
27     // did something fail?
28     if (!proc_ok) {
29     check_alert_error("CreateProcess");
30     return FALSE;
31     }
32 joko 1.1
33     // 1. background mode
34     if (background) {
35     // TODO: background process bookkeeping
36    
37     // 2. normal (blocking) mode
38     } else {
39     long status;
40     status = WaitForSingleObject(pi.hProcess, INFINITE);
41    
42     // close process and thread handles.
43     CloseHandle(pi.hProcess);
44     CloseHandle(pi.hThread);
45    
46     // check for and handle errors
47     if (status == WAIT_FAILED) {
48     check_alert_error("WaitForSingleObject");
49     return FALSE;
50     }
51     }
52    
53     return TRUE;
54    
55     }

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed