195 } 196 197 bool PosixProcess::ReadOutput() { 198 bool result = false; 199 200 if (FOutputHandle != 0 && IsRunning() == true) { 201 char buffer[4096] = {0}; 202 203 ssize_t count = read(FOutputHandle, buffer, sizeof (buffer)); 204 205 if (count == -1) { 206 if (errno == EINTR) { 207 // continue; 208 } else { 209 perror("read"); 210 exit(1); 211 } 212 } else if (count == 0) { 213 // break; 214 } else { 215 if (buffer[count - 1] == EOF) { 216 buffer[count - 1] = '\0'; 217 } 218 219 std::list<TString> output = Helpers::StringToArray(buffer); 220 FOutput.splice(FOutput.end(), output, output.begin(), output.end()); 221 result = true; 222 } 223 } 224 225 return false; 226 } 227 228 bool PosixProcess::IsRunning() { 229 bool result = false; 230 231 if (kill(FChildPID, 0) == 0) { 232 result = true; 233 } 234 235 return result; 236 } 237 238 bool PosixProcess::Terminate() { | 195 } 196 197 bool PosixProcess::ReadOutput() { 198 bool result = false; 199 200 if (FOutputHandle != 0 && IsRunning() == true) { 201 char buffer[4096] = {0}; 202 203 ssize_t count = read(FOutputHandle, buffer, sizeof (buffer)); 204 205 if (count == -1) { 206 if (errno == EINTR) { 207 // continue; 208 } else { 209 perror("read"); 210 exit(1); 211 } 212 } else if (count == 0) { 213 // break; 214 } else { 215 std::list<TString> output = Helpers::StringToArray(buffer); 216 FOutput.splice(FOutput.end(), output, output.begin(), output.end()); 217 result = true; 218 } 219 } 220 221 return false; 222 } 223 224 bool PosixProcess::IsRunning() { 225 bool result = false; 226 227 if (kill(FChildPID, 0) == 0) { 228 result = true; 229 } 230 231 return result; 232 } 233 234 bool PosixProcess::Terminate() { |