https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124330

--- Comment #4 from dave.anglin at bell dot net ---
On 2026-03-02 12:09 p.m., jvdelisle at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124330
> 
> --- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> What about something like this:
> 
> void
> shared_memory_set_env (pid_t pid)
> {
>   /* Increased size slightly to accommodate "ENV_VAR_NAME=" prefix for putenv
> */
>   char *buffer;
>   int res;
> 
> #if defined(HAVE_SETENV)
>   char val[20];
>   snprintf (val, 20, "%d", pid);
>   setenv (ENV_PPID, val, 1);
> #elif defined(_WIN32)
>   char val[20];
>   snprintf (val, 20, "%d", pid);
>   SetEnvironmentVariable (ENV_PPID, val);
> #else
>   /* HP-UX / Legacy Fallback using putenv */
>   res = asprintf (&buffer, "%s=%d", ENV_PPID, (int)pid);

HP-UX doesn't have asprintf but it does have snprintf.  Think ENV_PPID
needs to be character string and buffer a character array.  It size needs
to be 20 + 8;

>   if (res != -1)
>     putenv (buffer);

HP-UX has putenv but it doesn't have setenv.

> #endif
> }
> 

libgfortran builds on HP-UX 11.11 with the attached change.  I added code to
return
the number of processors.  Don't know if it works.

Reply via email to