I'm on a linux box and /proc/self/exe
does seem to be supported:
ls -l /proc/self/exe
shows that it's linked to /usr/bin/ls
at the moment I run the commandrealpath /proc/self/exe
prints out /usr/bin/realpath
as expected0
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?
This behavior would occur on glibc
versions below 2.3 as stated in man realpath
:
ERRORS
............
EINVAL -path
isNULL
. (In glibc versions before 2.3, this error is also returned ifresolved_path
isNULL
.)