hm... I don't think its a fork problem, since window really create a child for the writing thread to the file, its just that the parent thread cannot read it until its child is finish. I think its more or less a flushing problem? Do you agree?

Anyways, I now have the following code, and IE give me a page not found error, do you know why?

#!D:/Perl/bin/Perl.exe -w use strict; use CGI ":standard"; use IO::Handle; use Win32::Process; use Win32; $| = 1; my $MYFILE = "D:\\tmp"; my $share = "begin"; if (param("monitor")) { &monitor(); } else { Win32::Process::Create($Process, "D:\\ping.exe yahoo.com > + ${MYFILE}", "ping",0,DETACHED_PROCESS, ".") || +die "Create: $!"; } # print redirect(-uri => url() . "?monitor=yes", -nph=>1); } sub monitor { my $html = &draw_page(); if (defined $html) { print header(-refresh=>1, -nph=>1), $html; } else { print header(-nph=>1), &goodbye(); } } sub goodbye { return start_html(-title=>"Goodbye!") . h1("Goodbye!") . end_h +tml(); } sub get_number { open NUMBER, "<$MYFILE" or return undef; NUMBER->autoflush(1); my $number = <NUMBER>; close NUMBER; return $number; } sub draw_page { my $number = &get_number(); return (defined $number) ? start_html(-title=>"Your Lucky Numb +er") . p("Your lucky number is $number.") . end_html() : undef; } sub do_stuff { for my $i (1 .. 10) { open NUMBER, ">$MYFILE"; NUMBER->autoflush(1); print NUMBER "$i\n"; close NUMBER; sleep 1; } unlink $MYFILE; }

In reply to Re: Re: CGI real time update on Window/Apache problem by Anonymous Monk
in thread CGI real time update on Window/Apache problem by c24chan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.