| 1409 | } |
| 1410 | |
| 1411 | void kwsysProcess_Interrupt(kwsysProcess* cp) |
| 1412 | { |
| 1413 | int i; |
| 1414 | /* Make sure we are executing a process. */ |
| 1415 | if (!cp || cp->State != kwsysProcess_State_Executing || cp->TimeoutExpired || |
| 1416 | cp->Killed) { |
| 1417 | return; |
| 1418 | } |
| 1419 | |
| 1420 | /* Interrupt the children. */ |
| 1421 | if (cp->CreateProcessGroup) { |
| 1422 | if (cp->ForkPIDs) { |
| 1423 | for (i = 0; i < cp->NumberOfCommands; ++i) { |
| 1424 | /* Make sure the PID is still valid. */ |
| 1425 | if (cp->ForkPIDs[i]) { |
| 1426 | /* The user created a process group for this process. The group ID |
| 1427 | is the process ID for the original process in the group. */ |
| 1428 | kill(-cp->ForkPIDs[i], SIGINT); |
| 1429 | } |
| 1430 | } |
| 1431 | } |
| 1432 | } else { |
| 1433 | /* No process group was created. Kill our own process group. |
| 1434 | NOTE: While one could argue that we could call kill(cp->ForkPIDs[i], |
| 1435 | SIGINT) as a way to still interrupt the process even though it's not in |
| 1436 | a special group, this is not an option on Windows. Therefore, we kill |
| 1437 | the current process group for consistency with Windows. */ |
| 1438 | kill(0, SIGINT); |
| 1439 | } |
| 1440 | } |
| 1441 | |
| 1442 | void kwsysProcess_Kill(kwsysProcess* cp) |
| 1443 | { |