comparison lib/wait-process.c @ 40238:3ac749aa0041

fatal-signal: Pass the signal number to the action. * lib/fatal-signal.h (at_fatal_signal): Change the signature. * lib/fatal-signal.c (action_t): Take the signal number as parameter. (fatal_signal_handler): Pass the signal number to the action. * lib/clean-temp.c (cleanup_action): Renamed from cleanup. Take the signal number as parameter. (create_temp_dir): Update. * lib/wait-process.c (cleanup_slaves_action): New function. (register_slave_subprocess): Update at_fatal_signal invocation. * NEWS: Mention the change.
author Bruno Haible <bruno@clisp.org>
date Sat, 16 Mar 2019 22:56:21 +0100
parents b06060465f09
children
comparison
equal deleted inserted replaced
40237:b1386ce84ff5 40238:3ac749aa0041
100 kill (slave, TERMINATOR); 100 kill (slave, TERMINATOR);
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 /* The cleanup action, taking a signal argument.
106 It gets called asynchronously. */
107 static void
108 cleanup_slaves_action (int sig _GL_UNUSED)
109 {
110 cleanup_slaves ();
111 }
112
105 /* Register a subprocess as being a slave process. This means that the 113 /* Register a subprocess as being a slave process. This means that the
106 subprocess will be terminated when its creator receives a catchable fatal 114 subprocess will be terminated when its creator receives a catchable fatal
107 signal or exits normally. Registration ends when wait_subprocess() 115 signal or exits normally. Registration ends when wait_subprocess()
108 notices that the subprocess has exited. */ 116 notices that the subprocess has exited. */
109 void 117 void
111 { 119 {
112 static bool cleanup_slaves_registered = false; 120 static bool cleanup_slaves_registered = false;
113 if (!cleanup_slaves_registered) 121 if (!cleanup_slaves_registered)
114 { 122 {
115 atexit (cleanup_slaves); 123 atexit (cleanup_slaves);
116 at_fatal_signal (cleanup_slaves); 124 at_fatal_signal (cleanup_slaves_action);
117 cleanup_slaves_registered = true; 125 cleanup_slaves_registered = true;
118 } 126 }
119 127
120 /* Try to store the new slave in an unused entry of the slaves array. */ 128 /* Try to store the new slave in an unused entry of the slaves array. */
121 { 129 {