http://www.perlmonks.org?node_id=842789


in reply to Background process with perl and lighttpd

The problem is, that lighttpd buffers all output until all process terminate.

Have you tried to flush the output stream?

This should do the trick:

sub flush { my $fh = select( STDOUT ); my $hot = $|; $| = 1; print STDOUT ''; $| = $hot; select( $fh ); return; }

Replies are listed 'Best First'.
Re^2: Background process with perl and lighttpd
by zwon (Abbot) on Jun 02, 2010 at 19:46 UTC

      flushing the output does not work...

      The only thing that works is closing STDIN, STDOUT and STDERR. But then the script stops!

      This is what I have:

      my $q = new CGI; my $session = CGI::Session->load($q); my $tmpfile = $q->upload('upfile'); my $filename = $q->param('upfile'); print $q->redirect('showProgress.cgi'); close STDOUT; close STDIN; close STDERR; # <-- script stops here! append_file( 'debug', "start\n" );