- system("kill -TERM $pid >/dev/null 2>&1");
- # Give it twenty seconds to exit, otherwise valgrind can't write out all output before being killed -9
- # TODO make this a variable number based on if it's valgrind or normal start.
- sleep(20);
- if (getstatus() == 1)
- {
- print "InspIRCd not dying quietly -- forcing kill\n";
- system("kill -9 $pid >/dev/null 2>&1");
+ my $maxwait = (`ps -o command $pid` =~ /valgrind/i) ? 30 : 5;
+ kill TERM => $pid;
+ for (1..$maxwait) {
+ sleep 1;
+ if (getstatus() == 1) {
+ print "InspIRCd Stopped.\n";
+ return;
+ }