Re: How Does a Program Know Where it is Running?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[quoted lines by Karl Dahlke on 2004/05/02 at 19:58 +0000]

>getcwd()

No, that's not reliable since chdir() might've been called. getcwd() is only
reliable if it's called right at the start before any other code might've
called chdir(). Also, since argv[0] can ultimately be set to anything by the
invoker of the program, it isn't 100% reliable anyway. A common case in which
it, by definition, is wrong is when login prepends a minus sign to the name of
the shell.

-- 
Dave Mielke           | 2213 Fox Crescent | I believe that the Bible is the
Phone: 1-613-726-0014 | Ottawa, Ontario   | Word of God. Please contact me
EMail: dave@xxxxxxxxx | Canada  K2A 1H7   | if you're concerned about Hell.
http://familyradio.com/                   | http://mielke.cc/bible/


_______________________________________________

Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list

[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]