Home >Backend Development >PHP Tutorial >php pcntl_fork怎么关闭子进程

php pcntl_fork怎么关闭子进程

WBOY
WBOYOriginal
2016-06-06 20:23:222202browse

php pcntl_fork怎么关闭子进程

回复内容:

php pcntl_fork怎么关闭子进程

exit(0)//理论上这样是可以的,实际上这个进程会一直在,不知道为啥(php+apache)

posix_kill(posix_getpid(),SIGTERM);

另:实际使用时如果主进程要先退出,子进程继续执行的话,需要fork两次,让子进程退出再关闭父进程,直接业务逻辑让孙进程去执行

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn