A lengthy PHP process stuck in a loop:

I have a long PHP process that sometimes hangs in a loop. This is strace output, but I don't know what that 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) = 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 the cycle endless, and the process does not resume. What do the challenges above mean?

+4
source share
1 answer

Sorry, my previous answer was wrong. He waits endlessly:

 // Ignore SIGCHLD (Child process stopped or terminated) rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 // Set handler to SIGCHLD to default (ie 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 should install signal handlers in a loop, but this is the behavior caused by the following php code:

 while (true) { sleep(1); } 

I can not imagine the reason why you are calling sleep for non-debugging purposes in php, so look for any calls to sleep , usleep or time_nanosleep .

+2
source

All Articles