Date: Mon, 22 Jul 1996 18:03:33 +0200 (IST) From: Eli Zaretskii To: Orbital Cc: djgpp AT delorie DOT com Subject: Re: bug in exec/spawn ? In-Reply-To: Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 22 Jul 1996, Martynas wrote: > I wrote this program which loads its confguration file from the directory > where the executable is. I use argv[0] to determine it. However, when my > program is invoked from make or rhide, it can never find the cfg file. I > wrote a little test prg, smth like puts(argv[0]); and when invoked from > make or rhide it displays *only* its name, *without* the path. What gives? This is not a bug. The child gets in argv[0] *exactly* what the parent passes as the second argument to spawnXX function. If the parent doesn't bother to pass the full pathname there, the child won't get it. This is AFAIK how it should work. I'm not entirely sure, but I think this is also so on Unix. If you want your program to get its full pathname and argv[0] doesn't include it, you could look for it along the PATH (e.g., with `searchpath' library function; it looks in the current directory first). Just be sure to do that before the program changes to another directory, if that could ever happen.