Sample Header Ad - 728x90

The current path of a process

2 votes
1 answer
1753 views
Suppose I write a program, which outputs a file under a relative path (as opposed to a full/absolute path) - let's say, the current path. Then I compile it and store the executable under some dir path1. 1. Now I run the executable, while I am under a different dir path2. The executable will output a file under path2 instead of path1. I wonder why the executable doesn't write a file under path1 instead? In other words, why is the "current path" path2 not path1? 2. If during run-time, the executable opens a file stored in path3, why does the current path become path3, although I run the executable from path2 and the executable was stored in path1? How does the OS assign and change the current path for a process, during it's run-time?
Asked by Tim (106430 rep)
Jul 10, 2014, 05:22 AM
Last activity: Jun 23, 2019, 01:17 PM