Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
591 views
in Technique[技术] by (71.8m points)

process - How to check whether specified PID is currently running without invoking ps from PHP?

We would like to check if a specified process is currently running via PHP.

We would like to simply supply a PID and see if it is currently executing or not.

Does PHP have an internal function that would give us this information or do we have to parse it out of "ps" output?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are on Linux, try this :

if (file_exists( "/proc/$pid" )){
    //process with a pid = $pid is running
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...