| 374 | } |
| 375 | |
| 376 | static int runChild2(kwsysProcess* kp, char const* cmd[], int state, |
| 377 | int exception, int value, int share, int output, |
| 378 | int delay, double timeout, int poll, int disown, |
| 379 | int createNewGroup, unsigned int interruptDelay) |
| 380 | { |
| 381 | int result = 0; |
| 382 | char* data = 0; |
| 383 | int length = 0; |
| 384 | double userTimeout = 0; |
| 385 | double* pUserTimeout = 0; |
| 386 | kwsysProcess_SetCommand(kp, cmd); |
| 387 | if (timeout >= 0) { |
| 388 | kwsysProcess_SetTimeout(kp, timeout); |
| 389 | } |
| 390 | if (share) { |
| 391 | kwsysProcess_SetPipeShared(kp, kwsysProcess_Pipe_STDOUT, 1); |
| 392 | kwsysProcess_SetPipeShared(kp, kwsysProcess_Pipe_STDERR, 1); |
| 393 | } |
| 394 | if (disown) { |
| 395 | kwsysProcess_SetOption(kp, kwsysProcess_Option_Detach, 1); |
| 396 | } |
| 397 | if (createNewGroup) { |
| 398 | kwsysProcess_SetOption(kp, kwsysProcess_Option_CreateProcessGroup, 1); |
| 399 | } |
| 400 | kwsysProcess_Execute(kp); |
| 401 | |
| 402 | if (poll) { |
| 403 | pUserTimeout = &userTimeout; |
| 404 | } |
| 405 | |
| 406 | if (interruptDelay) { |
| 407 | testProcess_sleep(interruptDelay); |
| 408 | kwsysProcess_Interrupt(kp); |
| 409 | } |
| 410 | |
| 411 | if (!share && !disown) { |
| 412 | int p; |
| 413 | while ((p = kwsysProcess_WaitForData(kp, &data, &length, pUserTimeout))) { |
| 414 | if (output) { |
| 415 | if (poll && p == kwsysProcess_Pipe_Timeout) { |
| 416 | fprintf(stdout, "WaitForData timeout reached.\n"); |
| 417 | fflush(stdout); |
| 418 | |
| 419 | /* Count the number of times we polled without getting data. |
| 420 | If it is excessive then kill the child and fail. */ |
| 421 | if (++poll >= MAXPOLL) { |
| 422 | fprintf(stdout, "Poll count reached limit %d.\n", MAXPOLL); |
| 423 | kwsysProcess_Kill(kp); |
| 424 | } |
| 425 | } else { |
| 426 | fwrite(data, 1, (size_t)length, stdout); |
| 427 | fflush(stdout); |
| 428 | } |
| 429 | } |
| 430 | if (poll) { |
| 431 | /* Delay to avoid busy loop during polling. */ |
| 432 | testProcess_usleep(100000); |
| 433 | } |
no test coverage detected
searching dependent graphs…