This post originated from an RSS feed registered with Ruby Buzz
by Daniel Berger.
Original Post: When documentation lies
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
I hate it when the documentation is just WRONG. Take the getpwuid_r() function for example. When built with -D_POSIX_PTHREADS_SEMANTICS, the getpwuid_r() function is supposed to return 0 if there was no error. However, as far as I can tell the damned thing always returns 0 on my Solaris box.
And yet, AND YET, everything seems ok. It returns 0, and errno is not set but it segfaults when you get to the printf. WTF IS GOING ON?! Naturally I discovered this about 5 minutes after I released sys-admin.
That should have raised an error, but it doesn't. Why? I'm not sure. Maybe it's a bug in the Solaris POSIX implementation. I suppose I should post to comp.unix.solaris and see what the issue is.
Fortunately, there's an easy solution - just do a null check against pwdbuf. The only problem with that is that you only know that it failed. You won't know why it failed because errno isn't set.