| 2786 | } |
| 2787 | |
| 2788 | static void kwsysProcessesRemove(kwsysProcess* cp) |
| 2789 | { |
| 2790 | /* Attempt to remove the given signal pipe from the signal handler set. */ |
| 2791 | { |
| 2792 | /* Find the given process in the set. */ |
| 2793 | kwsysProcessInstances newProcesses = kwsysProcesses; |
| 2794 | int i; |
| 2795 | for (i = 0; i < newProcesses.Count; ++i) { |
| 2796 | if (newProcesses.Processes[i] == cp) { |
| 2797 | break; |
| 2798 | } |
| 2799 | } |
| 2800 | if (i < newProcesses.Count) { |
| 2801 | /* Remove the process from the set. */ |
| 2802 | --newProcesses.Count; |
| 2803 | for (; i < newProcesses.Count; ++i) { |
| 2804 | newProcesses.Processes[i] = newProcesses.Processes[i + 1]; |
| 2805 | } |
| 2806 | |
| 2807 | /* If this was the last process, disable the signal handler. */ |
| 2808 | if (newProcesses.Count == 0) { |
| 2809 | /* Restore the signal handlers. Repeat call until it is not |
| 2810 | interrupted. */ |
| 2811 | while ((sigaction(SIGCHLD, &kwsysProcessesOldSigChldAction, 0) < 0) && |
| 2812 | (errno == EINTR)) { |
| 2813 | } |
| 2814 | while ((sigaction(SIGINT, &kwsysProcessesOldSigIntAction, 0) < 0) && |
| 2815 | (errno == EINTR)) { |
| 2816 | } |
| 2817 | while ((sigaction(SIGTERM, &kwsysProcessesOldSigTermAction, 0) < 0) && |
| 2818 | (errno == EINTR)) { |
| 2819 | } |
| 2820 | |
| 2821 | /* Free the table of process pointers since it is now empty. |
| 2822 | This is safe because the signal handler has been removed. */ |
| 2823 | newProcesses.Size = 0; |
| 2824 | free(newProcesses.Processes); |
| 2825 | newProcesses.Processes = 0; |
| 2826 | } |
| 2827 | |
| 2828 | /* Store the new set in that seen by the signal handler. */ |
| 2829 | kwsysProcessesUpdate(&newProcesses); |
| 2830 | } |
| 2831 | } |
| 2832 | |
| 2833 | /* Close the pipe through which the signal handler may have notified |
| 2834 | the given process object that a child has exited. */ |
| 2835 | kwsysProcessCleanupDescriptor(&cp->SignalPipe); |
| 2836 | } |
| 2837 | |
| 2838 | static void kwsysProcessesSignalHandler(int signum |
| 2839 | #if KWSYSPE_USE_SIGINFO |
no test coverage detected
searching dependent graphs…