<?php
$dira = dirname(__DIR__);
$output = exec($dira . "\\htdocs\\PocketMine-MP-stable\\start.cmd");
echo $output
?>
I need to find a way to kill the process after starting it with exec() this is for a
exec returns Once the process terminates. So after exec you cannot kill the process as it Is no longer running. You have to run the process with proc_open And you can then kill it with proc_terminate.
EDIT:
Actualy you can have exec return earlier if you redirect output of the command to a file And append &
to the end of the command (or use nohup; Linux only maybe) so it runs in background. But getting the pid to send kill signal to it is only possible by name And that Is not very reliable
You may use posix_kill to kill a process with identifier pid.
Usage
//...
exec($dira . "\\htdocs\\PocketMine-MP-stable\\start.cmd", $output);
$pid = (int)$output[0];
$killed = posix_kill(int $pid , int $sig);
You should see all signals and their codes in your system using: kill -l
Check my Repl example