Ignore:
Timestamp:
2010-05-27T23:56:02+12:00 (14 years ago)
Author:
davidb
Message:

Some refinement of the testing framework for the os_process class

File:
1 edited

Legend:

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

    r22183 r22188  
    3737#endif
    3838
     39#include "text_t.h"
    3940#include "os_process_windows.h"
    4041
    41 //#include <stdio.h>
    42 
    43 osprocesswindows::osprocesswindows(char* cmdline)
    44   : osprocess(cmdline)
    45 {}
    4642
    4743osprocesswindows::osprocesswindows(OSProcessPipeMode mode,
    48                    char* prog_name, char* argv[]=NULL,
     44                   char* prog_name, char* argv[],
    4945                   char* envp[])
    5046  : child_stdout_read_(NULL), child_stdin_write_(NULL),
     
    9187 
    9288  si.dwFlags |= STARTF_USESTDHANDLES;
    93  
    94   // any error messages in child process to to same place as parent process
     89
     90 
     91  // any error messages in the child process goes to same place as parent
    9592  // e.g. in the case of running as a CGI script, the Web server error log
    9693  si.hStdError  = GetStdHandle(STD_ERROR_HANDLE);
    9794 
    98   // Output from the child process comes to the parent process, down the
    99   // OUT pipe
    100   si.hStdOutput = child_stdout_write;
    101  
    102   // Input to the child process can be sent from the parent process, down the
    103   // In pipe
    104   si.hStdInput = child_stdin_read;
    105  
    106   text_t cmd_line = "";
     95  if ((mode==uniRead) || (mode==biReadWrite)) {
     96    // Output from the child process comes to the parent process, down the
     97    // OUT pipe
     98    si.hStdOutput = child_stdout_write;
     99  }
     100  else {
     101    // uniWrite
     102    // Output from the chlid process goes to the same place as parent
     103    si.hStdOutput  = GetStdHandle(STD_OUTPUT_HANDLE);
     104  }
     105 
     106  if ((mode==uniWrite) || (mode==biReadWrite)) {
     107    // Input to the child process can be sent from the parent process, down the
     108    // In pipe
     109    si.hStdInput = child_stdin_read;
     110  }
     111  else {
     112    // uniRead
     113
     114    // Input to the child process comes from same place as parent ?!?
     115    si.hStdInput  = GetStdHandle(STD_INPUT_HANDLE);
     116  }
     117 
     118  text_t cmd_line = prog_name;
    107119  if (argv != NULL) {
    108     int i=0;
     120    int i=1;
    109121    while (argv[i] != NULL) {
    110       if (i>0) {
    111     cmd_line += " ";
    112       }
    113       cmd_line += "\"" + argv[i] + "\"";
     122      cmd_line += " \"";
     123      cmd_line += argv[i];
     124      cmd_line += "\"";
    114125      i++;
    115126    }
     
    162173
    163174
    164 int osprocesswindows::write(const char* buffer, const int buffer_len)
     175int osprocesswindows::write(char* buffer, const int buffer_len)
    165176{
    166177  DWORD actual_write_len;
     
    195206
    196207 
    197 bool osprocessunix::close_write_pipe(OSProcessWarnStatus warn_status)
     208bool osprocesswindows::close_write_pipe(OSProcessWarnStatus warn_status)
    198209{
    199210  bool write_close_ok = true;
    200211
    201   if (child_stdout_read_ != NULL) {
     212  if (child_stdin_write_ != NULL) {
    202213
    203214    write_close_ok = CloseHandle(child_stdin_write_);
     
    211222    }
    212223  }
    213   else if (warning_status == withWarning) {
     224  else if (warn_status == withWarning) {
    214225    cerr << "osprocesswindows::close_write_pipe(): Warning - Tried to close already closed pipe" << endl;
    215226  }
     
    219230
    220231
    221 bool osprocessunix::close_read_pipe(OSProcessWarnStatus warn_status)
     232bool osprocesswindows::close_read_pipe(OSProcessWarnStatus warn_status)
    222233{
    223234  bool read_close_ok = true;
Note: See TracChangeset for help on using the changeset viewer.