Is it possible to print from a perl CGI before the process exits?

我怕爱的太早我们不能终老 提交于 2019-12-13 00:34:32

问题


I have a perl CGI that needs to report some information back to the browser before it goes into a really lengthy process that frequently takes several minutes.

Currently I print the message but it doesn't show up till the entire process exits.

So, my question is:

Is it possible to get the message back to browser mid stream and if not

how do I spawn off a separate process to handle the lengthy bit, so that I can exit out of the initial process and thus have the user get the feedback they need.

The user doesn't need to be notified when the lengthy process is completed, so, I'm fine with quitting as long as the server keeps chugging at it.


回答1:


# Tell Perl not to buffer our output
$| = 1;


来源:https://stackoverflow.com/questions/3462838/is-it-possible-to-print-from-a-perl-cgi-before-the-process-exits

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!