getcwd(NULL, 0) revisited
By Casper Dik-Oracle on Sep 24, 2014
Earlier I claimed that the POSIX standard didn't allow an extension in which the following statement returned anything other than NULL while setting errno to EINVAL:
char *cwd = getcwd(NULL, 0);
However, standard also says:
"If buf is a null pointer, the behavior of getcwd() is unspecified."
so the GNU/Linux extension is perfectly legal. I was clearly wrong.
As many application check for this behavior when configuring, replacing the standard Solaris getcwd() with a concoction which runs much slower and fails more often, when Solaris getcwd() is found wanting, we're changing getcwd() to allocate sufficient memory when it is called with a buffer pointer of NULL and a size of zero.
Of course, you could already have that in Solaris 11, if you replaced getcwd(NULL, 0) with realpath(".", NULL).
Addendum: this fix is included in Solaris 11.2 SRU 3