On Wed, 2 Aug 2000, Todd Caine wrote:

> > STDOUT is where $r->print goes under mod_perl; you should be OK.
> 
> The data that is printed out via $r->print is on the file descriptor that the
> http request is set up on.  If the HTTP request came in on file descriptor 3
> then $r->print('foo') prints to file descriptor 3; not stdout(file descriptor
> 1, on my system).

right, Perl STDOUT != C stdout
 
> The only way I can get part of gif to the browser was to do this:
> 
> my $c = $r->connection;
> my $fd_num = $c->fileno(0);
> open(STDOUT, ">&$fd_num");
> RRDs::graph($args);
> 
> But the data is incomplete.  Even when I autoflush the $fd_num.
> There has got to be a better way.....

see Apache::Magick in the eagle book or at modperl.com.  it's still ugly
since it writes to a tmpfile, but it works.  you can also modify your c
sources to redfine stdout-ish calls, Apache::Peek does something like that
for redirecting stderr to the client socket:

#define PerlIO request_rec
#define PerlIO_printf rprintf
#define PerlIO_vprintf(r,fmt,vlist) \
 vbprintf(r->connection->client, fmt, vlist)
#define PerlIO_stderr() perl_request_rec(NULL)
#define PerlIO_putc(r,c) rputc(c,r)
#define PerlIO_puts(r,s) rputs(s,r)


Reply via email to