I found few sample codes too ! but I have difficulty in following the code.
If you've been following some threads here, you probably have seen
the classical Watching
long-running processes through CGI being mentioned. You could try to implement
something along these lines, and in case you get stuck, come back here
with the code you've tried and what exactly didn't work.
That would be for Unix systems. I can't comment on how to achieve
the same on Windows, because I've never run a webserver on Windows for
anything serious. But I suspect the system differences with respect to
fork/exec and how the webserver handles its pipes to the CGI program
might be large enough to require a slightly different approach...
Hopefully, someone else knows more.