Hi ChaosWong,

On 24/07/2013 2:59, ChaosWong wrote:
> I work under windows, and which platform do you work?

Linux and OS X.

> so I think it's never return 0, because 0 is usually represent "Standard 
> input (stdin)".
> If function fail, it should return -1, i think.

Yes, it will return -1 on error, but it can return 0 as well, if 
stdin/stdout/stderr are
closed (like for a daemon).

But that wasn't my main point, the solution that you and Robert worked out is 
correct (no
close in the error case).

After reading the code it is clear that 'parse(fd)' will actually close the file
descriptor when it's done reading.  Unless an error occurred, in which case the 
fd will
never be closed and effectively leak.

Also, if it succeeds with fd=0 it will close stdin!  Funny things can happen 
when you do that.

I realize that you didn't write the code but thought that if you're doing 
modifications in
that area this might be worth fixing as well.

Cheers,
/ulrich

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to