更新时间:2022-02-21 01:48:07
我建议您考虑使用proc_open
.您可以配置它以返回流资源,手动保留一个计时器,如果计时器在处理完成之前到期,则可以使用proc_terminate
终止它.如果确实在计时器到期之前完成,则可以使用proc_close
然后使用stream_get_contents
来抓取本来应该写入stdout的数据.
I would suggest you look into using proc_open
. You can configure it to return a stream resource, manually keep a timer, and if the timer expires before the process completes, you can terminate it with proc_terminate
. If it does complete before the timer expires, then you can use proc_close
then stream_get_contents
to grab the data that would have otherwise been written to stdout.