如何终止启动的PHP exec()的运行命令? [英] How to terminate the running command of PHP exec() launched?

查看:410
本文介绍了如何终止启动的PHP exec()的运行命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows操作系统,并且安装了沼泽系统.

我的问题是:

如何停止或终止启动的 PHP exec()运行命令?在我的情况下,我将同时启动几个命令,并且它是否具有类似于 ID 的名称,因此我可以停止我想要的正在运行的命令吗?

非常感谢您!

解决方案

我不确定使用Windows OS时是否适用相同的逻辑,但是您需要分两个步骤进行操作.

1)从php启动进程时-您需要进行分叉,以使您的实际PHP不会挂起.我已经习惯在perl中做到这一点,我确定php也会做到这一点.

2)无论启动什么程序,如果可以获取其PID,然后将其存储在数据库中.如果它是唯一的可执行文件名,那么只要有PID,就只需运行taskkill /IM uniquename.exetaskkill /PID ####即可.

I am using windows OS with wamp system installed.

My question is :

How to stop or terminate the running command of PHP exec() launched? In my situation,I will launch several command at the same time, and is it has something like IDs which corresponding,so I can stop the running command I want?

Thank you very much!!

解决方案

I'm not sure if the same logic applies when using Windows OS, but you will want to do it in two steps.

1) When you launch the process from php - you'll need to fork, so that your actual PHP doesn't hang. I'm used to doing it in perl, i'm sure php does it too.

2) Whatever program you launch, if you can get its PID then store it in a database. If it's a unique executable name then just run taskkill /IM uniquename.exe or taskkill /PID #### if you have the PID

这篇关于如何终止启动的PHP exec()的运行命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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