[Top][All Lists]

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

Re: getprocname Tru64

From: Jay K
Subject: Re: getprocname Tru64
Date: Tue, 6 Jul 2021 11:25:06 +0000

 > emulator

Do emulators like, are the process/executable from the kernel
point of view but implement their own loaders and load an executable? ok.
They should intercept aux queries though.

> link error

True it is a warning when building .so, and then
*tends* to work with all executables, given the same startup code.
I guess someone could write their own.

 > undocumented


I am not sure of the O_CLOEXEC there.
I know the intent, but I don't think it is a thing on Tru64/OSF1.

Other than removing O_CLOEXEC I tested the code and it works.

Thank you,
 - Jay

From: Bruno Haible <bruno@clisp.org>
Sent: Tuesday, June 29, 2021 3:04 PM
To: bug-gnulib@gnu.org <bug-gnulib@gnu.org>
Cc: Jay K <jayk123@hotmail.com>; Larkin Nickle <me@larbob.org>
Subject: Re: getprocname Tru64
Jay K wrote:
> I see I lost the race here, but here is my rendition of getprogname for Tru64, much more efficient.
> > diff -c getprogname.c.orig getprogname.c
> *** getprogname.c.orig  Tue Jun 29 03:46:44 2021
> --- getprogname.c       Tue Jun 29 03:48:55 2021
> ***************
> *** 283,288 ****
> --- 283,291 ----
>         close (fd);
>       }
>     return "?";
> + # elif defined __osf__
> +   extern char** __Argv;
> +   return last_component (__Argv[0]);
>   # else

But it seems that the use '__Argv' can cause link-time errors on Tru64. [1]

> I came to this by:
> 1: Looked in old gcc to find:
> #define MD_STARTFILE_PREFIX "/usr/lib/cmplrs/cc/"
> 2: grep/nm/dis there.
> I had hoped to step through the startup but haven't learned this dbx yet.

In other words, it's undocumented. In Gnulib, we avoid to rely on
undocumented stuff when possible. In some cases it is unavoidable,
but here we already have an implementation of getprogname() for

> There is also maybe "auxv" stuff.

That's not good. The result would not only depend on which executable
is running, but on how it was invoked (shell, emulator, valgrind, etc.).

> I find the proc file system kinda gross and inefficient but yeah.

If it's inefficient, you can add caching via a 'static' variable.
Like we already do in the implementations for AIX and HP-UX.


[1] https://na01.safelinks.protection.outlook.com/?url="">

reply via email to

[Prev in Thread] Current Thread [Next in Thread]