Finding current executable's path without /proc/self/exe

前端 未结 13 835
有刺的猬
有刺的猬 2020-11-22 01:06

It seems to me that Linux has it easy with /proc/self/exe. But I\'d like to know if there is a convenient way to find the current application\'s directory in C/C++ with cros

13条回答
  •  不思量自难忘°
    2020-11-22 01:51

    AFAIK, no such way. And there is also an ambuiguity: what would you like to get as the answer if the same executable has multiple hard-links "pointing" to it? (Hard-links don't actually "point", they are the same file, just at another place in the FS hierarchy.) Once execve() successfully executes a new binary, all information about its arguments is lost.

提交回复
热议问题