Long running PHP process stuck in loop - strace output included
I have a long running PHP process, that sometimes hangs in a loop. This is the strace output, but I don't know what it means:
nanosleep({1, 0}, {1, 0}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({1, 0}, {1, 0}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8开发者_如何学C) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({1, 0}, {1, 0}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({1, 0}, <unfinished ...>
The calls above keep looping indefinitely, and the process doesn't recover. What do the calls above mean?
Sorry, my previous answer was wrong. It waits infinitely:
// Ignore SIGCHLD (Child process stopped or terminated)
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
// Set handler to SIGCHLD to default (i.e. ignore)
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
// Un-ignore SIGCHLD
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
// Sleep for a second
nanosleep({1, 0}, {1, 0}) = 0
I have no idea why you would install signal handlers in a loop, but this is the behavior caused by the following php code:
while (true) {
sleep(1);
}
I cannot imagine a reason why you would call sleep for non-debugging purposes in php, so look for any invocations of sleep
, usleep
or time_nanosleep
.
精彩评论