MCPcopy Create free account
hub / github.com/Kitware/CMake / kwsysProcessesRemove

Function kwsysProcessesRemove

Source/kwsys/ProcessUNIX.c:2788–2836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2786}
2787
2788static 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
2838static void kwsysProcessesSignalHandler(int signum
2839#if KWSYSPE_USE_SIGINFO

Callers 1

kwsysProcessCleanupFunction · 0.70

Calls 3

kwsysProcessesUpdateFunction · 0.85
sigactionClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…