如何找出特定进程仍在 PHP 中运行 [英] how to find out a specific process is still running in PHP

查看:40
本文介绍了如何找出特定进程仍在 PHP 中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本来构建其他脚本的队列,并应该管理它们的启动.管理器脚本应该知道哪个子进程已经完成,所以它可以启动在队列中等待的其他脚本.

我添加了& echo $!"获取每个子进程的进程 ID.所以我有我的子进程进程 ID,现在我使用系统ps"程序调用来查找子进程是否仍在运行.

问题是我的脚本目前只能在类 Unix 系统中运行.我不知道如何在 windows 中获取我孩子的 PID,而且我的脚本还没有在 windows 中解析tasklist"命令的输出.

有没有其他方法可以实现这一目标?任何用于查找子进程是否仍在运行的 PHP 内解决方案?启动其他进程(非阻塞)并检查它们是否仍在运行的解决方案.

解决方案

您是否尝试过 proc_get_status() ?在这种情况下,您可能希望使用 proc_open() 生成子进程.我不确定这是否是您要找的.

I'm writing a script that builds a queue of other scripts and is supposed to manage their launch. the manager script should know which child process has finished, so it can launch other scripts waiting in the queue.

I added a "& echo $!" to get the Process Id of each child process. so I have my child processes Process Ids, and for now am using system "ps" program call to find if child processes are still running or not.

the thing is that my script currently runs only in Unix-like systems. I don't know how to fetch my children's PID in windows, and my script does not parse "tasklist" command's output in windows yet.

Is there any other way to achieve this? any in-PHP solution to find if the child process is still running? a solution to start other processes (non blocking), and check if they are still running or not.

解决方案

Have you tried proc_get_status() ? In that case you may want to spawn your child processes using proc_open(). Im not sure if this is what your looking for.

这篇关于如何找出特定进程仍在 PHP 中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆