Commit 6242752
authored
make ExecStop wait for pid to die (hestiacp#2772)
the previous ExecStop would send the TERM signal and return immidately. the new ExecStop will send SIGTERM then hang until the pid actually dies, similar to Debian/Ubuntu's "sudo sedvice hestia-php stop". sleep(0) is a neat little hack basically do the equivalent of pthread_yield(), turns the CPU usage from 100%-of-1-core to 15%-of-1-core, sleeping very fast.. which is required because there is a race condition here that is very hard to fix: if the pid is re-used between scans, we won't notice the pid has actually died and been resurrected.
Even "killall -w" is suspectible to this race condition bug, and the fact that even GNU Coreutils's Killall have fixed it, is an indication that fixing this race condition bug is probably very difficult, the easiest course of action is probably to sleep very little, ie pthread_yield();1 parent f835997 commit 6242752
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments