Skip to content

Commit 0c6ff5e

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Try SIGTERM before SIGKILL in opcache restart
2 parents 5cb25a2 + 8b7aaad commit 0c6ff5e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,14 +767,15 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
767767
/* so that other process won't try to force while we are busy cleaning up */
768768
ZCSG(force_restart_time) = 0;
769769
while (mem_usage_check->l_pid > 0) {
770-
/* Clear previous errno, reset success and tries */
770+
/* Try SIGTERM first, switch to SIGKILL if not successful. */
771+
int signal = SIGTERM;
771772
errno = 0;
772773
success = 0;
773774
tries = 10;
774775

775776
while (tries--) {
776777
zend_accel_error(ACCEL_LOG_WARNING, "Attempting to kill locker %d", mem_usage_check->l_pid);
777-
if (kill(mem_usage_check->l_pid, SIGKILL)) {
778+
if (kill(mem_usage_check->l_pid, signal)) {
778779
if (errno == ESRCH) {
779780
/* Process died before the signal was sent */
780781
success = 1;
@@ -797,6 +798,8 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
797798
break;
798799
}
799800
usleep(10000);
801+
/* If SIGTERM was not sufficient, use SIGKILL. */
802+
signal = SIGKILL;
800803
}
801804
if (!success) {
802805
/* errno is not ESRCH or we ran out of tries to kill the locker */

0 commit comments

Comments
 (0)