clinuxrealpath

realpath() in my env doesn't like NULL as second argument?


I'm on a linux box and /proc/self/exe does seem to be supported:

But:

if (NULL == realpath("/proc/self/exe", NULL))
{
  printf("this prints unexpectedly, %s\n", strerror(errno));
}

At this point, errno is 22 and I see Invalid argument. Why? Or -- how does one figure out why?


Solution

  • This behavior would occur on glibc versions below 2.3 as stated in man realpath:

    ERRORS
    ............
    EINVAL - path is NULL. (In glibc versions before 2.3, this error is also returned if resolved_path is NULL.)