> 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 Indeed. 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 Sent: Tuesday, June 29, 2021 3:04 PM To: bug-gnulib@gnu.org Cc: Jay K ; Larkin Nickle 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 OSF/1. > 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. Bruno [1] https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-help%2F%2F2004-January%2F044699.html&data=04%7C01%7C%7C862a06f8085c48b64b3e08d93b0f34a7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637605758753944531%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=UT6O%2Bb32VETYGALCLYynBm0oamrOehw2wjLwcqsgI0I%3D&reserved=0