| 1434 | } |
| 1435 | |
| 1436 | void kwsysProcess_Kill(kwsysProcess* cp) |
| 1437 | { |
| 1438 | int i; |
| 1439 | /* Make sure we are executing a process. */ |
| 1440 | if (!cp || cp->State != kwsysProcess_State_Executing || cp->TimeoutExpired || |
| 1441 | cp->Killed) { |
| 1442 | KWSYSPE_DEBUG((stderr, "kill: child not executing\n")); |
| 1443 | return; |
| 1444 | } |
| 1445 | |
| 1446 | /* Disable the reading threads. */ |
| 1447 | KWSYSPE_DEBUG((stderr, "kill: disabling pipe threads\n")); |
| 1448 | kwsysProcessDisablePipeThreads(cp); |
| 1449 | |
| 1450 | /* Skip actually killing the child if it has already terminated. */ |
| 1451 | if (cp->Terminated) { |
| 1452 | KWSYSPE_DEBUG((stderr, "kill: child already terminated\n")); |
| 1453 | return; |
| 1454 | } |
| 1455 | |
| 1456 | /* Kill the children. */ |
| 1457 | cp->Killed = 1; |
| 1458 | for (i = 0; i < cp->NumberOfCommands; ++i) { |
| 1459 | kwsysProcessKillTree(cp->ProcessInformation[i].dwProcessId); |
| 1460 | /* Remove from global list of processes and close handles. */ |
| 1461 | kwsysProcessesRemove(cp->ProcessInformation[i].hProcess); |
| 1462 | kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hThread); |
| 1463 | kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hProcess); |
| 1464 | } |
| 1465 | |
| 1466 | /* We are killing the children and ignoring all data. Do not wait |
| 1467 | for them to exit. */ |
| 1468 | } |
| 1469 | |
| 1470 | void kwsysProcess_KillPID(unsigned long process_id) |
| 1471 | { |
no test coverage detected
searching dependent graphs…