195
191
// killed): Unfortunately, it's possible on Linux that the main PID of
196
192
// the process has been successfully killed (and is waiting to be
197
193
// reaped while in a defunct state), while some of the other threads
198
// of the process just don't want to go away. Integrate ink_killall
199
// into Kill() and KillAll() just to make sure we really kill
200
// everything and so that we don't spin hard while trying to kill a
194
// of the process just don't want to go away.
202
195
//-------------------------------------------------------------------------
205
198
lockfile_kill_internal(pid_t init_pid, int init_sig, pid_t pid, const char *pname, int sig)
214
// Need to grab pname's pid vector before we issue any kill signals.
215
// Specifically, this prevents the race-condition in which
216
// traffic_manager spawns a new traffic_server while we still think
217
// we're killall'ing the old traffic_server.
219
ink_killall_get_pidv_xmalloc(pname, &pidv, &pidvcnt);
223
kill(init_pid, init_sig);
224
// sleep for a bit and give time for the first signal to be
230
if ((err = kill(pid, sig)) == 0) {
233
if (pname && (pidvcnt > 0)) {
234
ink_killall_kill_pidv(pidv, pidvcnt, sig);
237
} while ((err == 0) || ((err < 0) && (errno == EINTR)));
244
kill(init_pid, init_sig);
245
// sleep for a bit and give time for the first signal to be
204
kill(init_pid, init_sig);
205
// Wait for children to exit
207
err = waitpid(-1, &status, WNOHANG);
208
if (err == -1) break;
209
} while(!WIFEXITED(status) && !WIFSIGNALED(status));
251
213
err = kill(pid, sig);
252
214
} while ((err == 0) || ((err < 0) && (errno == EINTR)));
254
#endif // linux check
295
255
if ((pid < 0) || (pid == getpid()))
296
256
pid = holding_pid;
259
// This way, we kill the process_group:
301
// We kill the holding_pid instead of the process_group
302
// initially since there is no point trying to get core files
303
// from a group since the core file of one overwrites the core
304
// file of another one
261
// In order to get core files from each process, please
262
// set your core_pattern appropriately.
305
263
lockfile_kill_internal(holding_pid, initial_sig, pid, pname, sig);