Ignore:
Timestamp:
2010-05-27T11:32:46+12:00 (14 years ago)
Author:
davidb
Message:

Further expansion of functionality (and testing) or os_process classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/os_process_windows.cpp

    r22177 r22183  
    4545{}
    4646
    47 osprocesswindows::osprocesswindows(char* cmdline, OSProcessPipeMode mode)
     47osprocesswindows::osprocesswindows(OSProcessPipeMode mode,
     48                   char* prog_name, char* argv[]=NULL,
     49                   char* envp[])
    4850  : child_stdout_read_(NULL), child_stdin_write_(NULL),
    49     osprocess(cmdline,mode)
     51    osprocess(mode,prog_name,argv,envp)
    5052{
    5153  HANDLE child_stdin_read = NULL;
     
    102104  si.hStdInput = child_stdin_read;
    103105 
     106  text_t cmd_line = "";
     107  if (argv != NULL) {
     108    int i=0;
     109    while (argv[i] != NULL) {
     110      if (i>0) {
     111    cmd_line += " ";
     112      }
     113      cmd_line += "\"" + argv[i] + "\"";
     114      i++;
     115    }
     116  }
     117
     118  char* cmd_line_cstr = cmd_line.getcstr();
     119
    104120  int rv = CreateProcess(NULL,    // no application name
    105              cmdline,
     121             cmd_line_cstr,
    106122             NULL,
    107123             NULL,    // no process or thread security attribues
     
    112128             &si,
    113129             &pi_);    // process info filled out as a result
     130
     131  delete [] cmd_line_cstr;
     132
    114133  if (!rv) {
    115     cerr << "os_process_windows(): Error creating process" << endl;
     134    cerr << "os_process_windows(): Error creating child process" << endl;
    116135  }
    117136
     
    119138
    120139  if (!CloseHandle(child_stdout_write)) {
    121     cerr <<  "os_process_windows(): Error closing StdOutWr Handle" << endl;
     140    cerr <<  "os_process_windows(): Error closing child's StdOut Write Handle" << endl;
    122141  }
    123142
    124143  if (!CloseHandle(child_stdin_read)) {
    125     cerr << "os_process_windows(): Error closing StdInRd Handle" << endl;
     144    cerr << "os_process_windows(): Error closing child's StdIn Read Handle" << endl;
    126145  }
    127146
     
    170189
    171190
     191void osprocesswindows::wait()
     192{
     193  WaitForSingleObject(pi_.hProcess, INFINITE);
     194}
    172195
    173196 
Note: See TracChangeset for help on using the changeset viewer.