php依据文件不同关闭同名进程

WBOY
Release: 2016-06-13 12:49:32
Original
773 people have browsed it

php根据文件不同关闭同名进程
比如有个 a.exe 在 C:\test 和 C:\test\test 目录下,在两个目录下把a.exe都运行,然后任务管理器里面就出现了两个a.exe  怎么用php关闭,指定目录下的a.exe   比如我想关闭C:\test\test 下的运行的a.exe该怎么办   


------解决方案--------------------
windows不了解。

linux下,运行一个进程后都会有一个唯一的pid。可以通过一个shell脚本来运行php脚本的进程作为其子进程,运行后可以得到各自的pid,然后kill的时候直接kill相关的pid既可。

php本身也可以通过getmypid函数获取当前脚本进程pid。不过似乎是不能杀死自身进程,还是需要个master进程对来控制。

python不太会,如果是ruby的话,程序自己也能获得pid,但貌似也无法杀死自己。
最简单的方法就是用shell做主控进程。
------解决方案--------------------
向操作系统发出相应的命令就可以了
但遗憾的是:你做不到,因为 php 没有足够的权限
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!