6月 282012
 

引子:
PHP的popen可以并发调起多个进程吗?

我们做如下测试:
测试1

分析1
我们发现,这里只输出了"a", 没有输出"b",说明sleep 100;执行了, sleep 200; 没有立即执行

测试2

分析2
这里a、b都输出了,说明两条命令都被调起执行了;同时,我们也发现,主进程并没有立即退出,而是在等待所有子进程执行完毕,如果使用 "&" 将启动的命令推倒后台,主进程也就不等待了。

测试3

分析3
这里a没有输出,说明如果不将popen赋值给一个变量,则进程阻塞,如果使用 "&" 将启动的命令推倒后台,则亦不阻塞。

 Posted by at 下午 10:00

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据