How do I create a file in the same directory as the executable when run by root? : <p>I have a program written in C that creates and reads a config file. It assumes that the config file is in the same directory as it is.</p>

<p>The program is run by fcron as root. If root runs this program, then the config file is created in root's home directory. It needs to be created in the user's directory where the program is.</p>

<p>I don't know enough about user management in linux to solve this, so the only way I can think to solve this is to get the executable's path by modifying argv[0].</p>

<p>Is there a better way?</p>
