How does the Shell-linux kill PHP process affect the life cycle of PHP?

Source: Internet
Author: User
Keywords Php shell linux

If I kill PHP, the process

Will the PHP process execute the __destruct () destructor?

What is the impact on the life cycle of PHP?

I think that Linux kill is out of the control of PHP, and the PHP life cycle has no relationship, is this understanding?
If so, who does the PHP process use to maintain the memory?

Another: If my demand is: Notify the end of the PHP process (such as PHP is currently a dead loop), so that PHP itself to complete the life cycle, how to deal with it?

Reply content:

If I kill PHP, the process

Will the PHP process execute the __destruct () destructor?

What is the impact on the life cycle of PHP?

I think that Linux kill is out of the control of PHP, and the PHP life cycle has no relationship, is this understanding?
If so, who does the PHP process use to maintain the memory?

Another: If my demand is: Notify the end of the PHP process (such as PHP is currently a dead loop), so that PHP itself to complete the life cycle, how to deal with it?

Similar to forcing the end of a process under Windows, you will be prompted to lose the data because the process does not knowingly end abruptly and does not handle the aftermath effectively.

The kill process is no longer in the scope of PHP management, which is a system level.

Therefore, the destructor will not execute, because the premise of execution is PHP active trigger, now PHP is gone.

Before kill, the memory is applied according to the configuration, and PHP maintains and recycles itself. The memory release after Kill is of course the Linux maintenance, even if the remaining zombie process, is also system management.

Notify PHP process end, you can try the signal, FPM comes with signal processing, restart, stop and so on.

Typically, PHP code does not normally capture the signal that the kill sends.
And I'm not sure PHP is capable of capturing it.

Another: If my demand is: Notify the end of the PHP process (such as PHP is currently a dead loop), so that PHP itself to complete the life cycle, how to deal with it?

Workaround

开始时间 = 当前时间生命周期时间 = 300while(ture){     if (当前时间 - 开始时间) >=300         退出     else         执行业务逻辑}

Do not meet the main demand ~ quiet to the Wise

Kill a process, the memory of the process is of course recycled by the operating system
If you have a demand for signal capture, see PHP's Pcntl extension

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.