- Timestamp:
- 2010-05-26T23:52:09+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/recpt/os_process_windows.cpp
r22173 r22177 130 130 osprocesswindows::~osprocesswindows() 131 131 { 132 // close any file handles that are still open 133 close(); 134 132 135 // Close process and thread handles 133 136 CloseHandle( pi_.hProcess ); … … 137 140 pi_.hThread = NULL; 138 141 } 139 140 141 /*142 bool osprocesswindows::eop()143 {144 }145 146 bool osprocesswindows::eop(OSProcessPipeMode)147 {148 }149 */150 142 151 143 … … 178 170 179 171 180 bool osprocesswindows::close() { 181 return true; 182 } 183 184 bool osprocesswindows::close(OSProcessPipeMode mode) 185 { 186 // Close the pipe handle so the child process stops reading. 187 188 if (!CloseHandle(child_stdin_write_)) { 189 cerr << "osprocesswindows::close(): Failed to close stdin write handle on pipe to child process" << endl; 190 return false; 191 } 192 193 if (!CloseHandle(child_stdout_read_)) { 194 cerr << "osprocesswindows::close(): Failed to close handle stdout read on pipe to chlild process" << endl; 195 return false; 196 } 197 198 199 return true; 200 } 201 202 203 204 205 206 //#ifdef TEST_OS_PROCESS_WINDOWS 207 #if 0 208 209 int main () 210 { 211 char* input_line = NULL; 212 char* prog_name = "c:\\Windows\\system32\\java.exe"; 213 char* cmd_line = "java"; 214 215 //char* input_line = "echo hi there\n"; 216 //char* prog_name = "c:\\cygwin\\bin\\cat.exe"; 217 //char* cmd_line = "cat"; 218 219 osprocesswindows osprocess(cmd_line,uniRead); 220 221 printf("Content-type: text/html\n\n"); 222 223 printf( "<html>\n"); 224 printf( " <head>\n"); 225 printf( " <title>Testing</title>\n"); 226 printf( " </head>\n"); 227 printf( " <body>\n"); 228 229 230 const int BufferSize = 1024; 231 char buffer[BufferSize]; 232 233 int bytes_read = 0; 234 do { 235 bytes_read = osprocess.read(buffer,BufferSize); 236 if (bytes_read>0) { 237 fwrite(buffer,1,bytes_read,stdout); 238 } 239 } while (bytes_read==BufferSize); 240 241 242 printf( " </body>\n"); 243 printf( "</html>\n"); 244 245 return 0; 246 } 172 173 174 bool osprocessunix::close_write_pipe(OSProcessWarnStatus warn_status) 175 { 176 bool write_close_ok = true; 177 178 if (child_stdout_read_ != NULL) { 179 180 write_close_ok = CloseHandle(child_stdin_write_); 181 182 if (write_close_ok) { 183 child_stdin_write_ = NULL; 184 } 185 else { 186 // not OK 187 cerr << "osprocesswindows::close(): Error - Failed to close stdin write handle on pipe to child process" << endl; 188 } 189 } 190 else if (warning_status == withWarning) { 191 cerr << "osprocesswindows::close_write_pipe(): Warning - Tried to close already closed pipe" << endl; 192 } 193 194 return write_close_ok; 195 } 196 197 198 bool osprocessunix::close_read_pipe(OSProcessWarnStatus warn_status) 199 { 200 bool read_close_ok = true; 201 202 if (child_stdout_read_ != NULL) { 203 204 read_close_ok = CloseHandle(child_stdout_read_); 205 206 if (read_close_ok) { 207 child_stdout_read_ = NULL; 208 } 209 else { 210 cerr << "osprocesswindows::close(): Error - Failed to close handle stdout read on pipe to chlild process" << endl; 211 } 212 } 213 else if (warn_status == withWarning) { 214 cerr << "osprocesswindows::close_read_pipe(): Warning - Tried to close already closed pipe" << endl; 215 } 216 217 return read_close_ok; 218 } 219 220 221 222 223 224 225 247 226 248 227 #endif 249 250 #endif
Note:
See TracChangeset
for help on using the changeset viewer.