[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: stdout?

From: Kevin Pilch-Bisson <kevin_at_pilch-bisson.net>
Date: 2001-01-26 15:23:51 CET

Okay, here I am replying to my own messages, which I didn't even manage
to send to the list.

On Fri, Jan 26, 2001 at 09:16:36AM -0500, Kevin Pilch-Bisson wrote:
> On Fri, Jan 26, 2001 at 08:15:52AM -0600, Ben Collins-Sussman wrote:
> > Greg Stein <gstein@lyra.org> writes:
> >
> > > #include <unistd.h>
> > > #include <apr_portable.h>
> > >
> > > {
> > > apr_file_t *file = NULL; /* ### grumble. NULL needed... */
> > >
> > > status = apr_put_os_file(&file, STDOUT_FILENO, pool);
> > > return file;
> > > }
> > >
> > > There ya go! :-)
> > >
> > > The put_os thing is os-specific, so it isn't portable.
> > >
> >
> > Hmmm, I get a compile warning that arg 2 is implicitly converting an
> > integer to a pointer. If I cast it in place ((apr_os_file_t *)
> > STDOUT_FILENO), then it compiles fine, but I get a segfault right in
> > the middle of apr_put_os_file()!
>
>
> It sounds to me like it is a file descriptor versuse FILE * problem,
> but that is just a guess of the top of my head.
> >
> > (Specifically, in file_io/unix/open.c, line 227 where it tries to set
> > ->filedes).
> As in you are giving it a file descriptor, but it is treating it like a
> FILE *. Try just passing it stdout instead of STDOUT_FILENO.
>
After actually looking at the APR stuff, instead of just spouting off
the top of my head, apr_os_file_t is typefef'd to int. This means that
I think you need to be passing &STDOUT_FILENO. The reason it is a
poiner is that some other OSes (Windows Notably), have structs as the
native file type.

Anyway try status = apr_put_os_file(&file, &STDOUT_FILENO, pool). My
guess is that your segfault was because you casted an int to a pointer,
and then the filedes assignment dereferenced that pointer.

Once again, sorry for not thinking before I hit send, and sorry for
missing the list.

-- 
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Pilch-Bisson
kevin@pilch-bisson.net
http://www.pilch-bisson.net
PGP Public Key At http://pgp.pilch-bisson.net

  • application/pgp-signature attachment: stored
Received on Sat Oct 21 14:36:20 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.