是否可以阻止 zend 引擎释放资源?
是否可以阻止 zend 引擎释放 PHP 中分配的资源?
例如,当一个进程被forked()并且资源被复制到子进程时,当子进程或父进程退出时,资源是空闲的,因此其他进程不能再访问它们。
Is it possible to prevent zend engine to free resources allocated in PHP?
For example, when a process is forked() and the resource is duplicated to the child process, when either child process or parent process exit, the resource is free thus other processes can't access them any more.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
释放资源不是问题,因为父级和子级无法访问彼此的资源。也许你说的是mysql连接。问题是,即使你不调用
mysql_close()
它也会被 php.ini 调用。这是一个例子,我听说父级可以通过使用
SIGKILL
杀死自己来防止这种情况,但我还没有测试过。应该是这样的:或者如果父进程启动了许多子进程,并且它们在退出时关闭了与数据库的连接,您可以对子进程使用相同的方法。
Freeing resourses is not the problem, because the parent and child have no access to each other's resourses. Maybe you are talking about mysql connection. The problem is that even if you don't call
mysql_close()
it's called by php. This is an exampleI heard that parent can prevent this by killing itself with
SIGKILL
, but I haven't tested it. Should be something like:Or if parent starts many children and they close connection to database on quit you can use the same approach on children.