Re: determining the program_invocation_name

2010-12-27 Thread Eric Blake
On 12/24/2010 02:41 PM, Bruno Haible wrote: > Hi, > > How can some library code determine the name of the running program, > for error message and display purposes, if the program's main() function > has not stored argv[0] in a particular place? > > Let's be clear about two things: > > 1) This

Re: determining the program_invocation_name

2010-12-25 Thread Bastien ROUCARIES
On Sat, Dec 25, 2010 at 5:32 PM, Bruno Haible wrote: > Hello Bastien, > >> We could at least in all the case implement getprogname/setprogname >> what is a well known api > > We can implement something _similar_ to getprogname. But it won't be > the same API, because >  - our function can return N

Re: determining the program_invocation_name

2010-12-25 Thread Bruno Haible
Hello Bastien, > We could at least in all the case implement getprogname/setprogname > what is a well known api We can implement something _similar_ to getprogname. But it won't be the same API, because - our function can return NULL, - our function can return a truncated value, - there wil

Re: determining the program_invocation_name

2010-12-25 Thread Bastien ROUCARIES
> Find attached a collection of the platform dependent code snippets. > I added code for Cygwin, mingw (from progreloc.c), and OSF/1, and > tested it on the various platforms. See also http://stackoverflow.com/questions/799679 for bsd: int mib[4]; mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KER

Re: determining the program_invocation_name

2010-12-25 Thread Bastien ROUCARIES
n Sat, Dec 25, 2010 at 4:38 PM, Bastien ROUCARIES wrote: > On Fri, Dec 24, 2010 at 10:41 PM, Bruno Haible wrote: >> Hi, >>     Given B, you can determine C, D, E, by assuming the current directory >>     and $PATH have not changed since the program was launched. > > Or better, in a lot of system

Re: determining the program_invocation_name

2010-12-25 Thread Bastien ROUCARIES
On Fri, Dec 24, 2010 at 10:41 PM, Bruno Haible wrote: > Hi, >     Given B, you can determine C, D, E, by assuming the current directory >     and $PATH have not changed since the program was launched. Or better, in a lot of system when the library is loaded you could run some kind of constructor/

Re: determining the program_invocation_name

2010-12-24 Thread Paul Eggert
On 12/24/2010 01:41 PM, Bruno Haible wrote: > Decide that it is better to have no gnulib API at all than an API that > has portability problems. Given the results of your (impressive) research, I'm tempted to go with this approach. A fallback position might be to implement only A (the sh

determining the program_invocation_name

2010-12-24 Thread Bruno Haible
Hi, How can some library code determine the name of the running program, for error message and display purposes, if the program's main() function has not stored argv[0] in a particular place? Let's be clear about two things: 1) This question is mostly irrelevant for libposix, because library