2

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 command
  • realpath /proc/self/exe prints out /usr/bin/realpath as expected
  • both commands exit with status 0

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?

user1011471
  • 1,090
  • 2
  • 14
  • 34

1 Answers1

4

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.)

Eugene Sh.
  • 17,802
  • 8
  • 40
  • 61