When calling the getcwd (Ubuntu 16.04 OS, gcc 5.4), an error occurs indicating that the executable file is not associated with any directory - the error code is 2 ENOENT . In the context of calling this function, it should be interpreted as:
The current working directory has been unlinked
which I, in fact, said above.
Sketched a separate program, where this function is called - it works correctly, and the output is the result corresponding to the current directory. From this I conclude that in the program where I decided to apply this function there are some factors that influence its execution. What tell me?
For example, in the code oriented under the Nix (cross-platform application), when starting, close the streams:
fclose(stdin); fclose(stdout); fclose(stderr); Can not these actions become the very reason why getcwd does not work the way I expect?
ls -al /proc/<pid>/cwd- KoVadim