bug-gnulib
[Top][All Lists]
Advanced

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

Re: trimming getloadavg's dependencies


From: Bruno Haible
Subject: Re: trimming getloadavg's dependencies
Date: Mon, 7 Feb 2011 11:46:48 +0100
User-agent: KMail/1.9.9

Hi Paul,

> +      while (*ptr == ' ')
> +        ptr++;
>  
> +      if (! ('0' <= *ptr && *ptr <= '9'))

Between these lines a comment could be useful:

      /* Parse a floating-point number.  No minus sign and no exponent is
         expected, just  (DIGIT)+ ['.' (DIGIT)*]  */

> -          /* Set the channel to close on exec, so it does not
> -             litter any child's descriptor table.  */
> -          set_cloexec_flag (channel, true);
> -          getloadavg_initialized = true;
> +          if (fd <= STDERR_FILENO)
> +            {
> +#   ifdef F_DUPFD_CLOEXEC
> +              int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
> +              close (fd);
> +              fd = fd1;
> +#   endif
> +            }

You can put the #ifdef outside the if (fd <= STDERR_FILENO) statement, I think.

This piece of code is used on IRIX, as far as I can see (because
AIX has libperfstat, Solaris >= 7 has getloadavg(), and older Solaris
has libkstat). According to doc/posix-headers/fcntl.texi, F_DUPFD_CLOEXEC
is missing on Solaris. So this patch seems to be a small safety regression
on IRIX. But I agree with you, it's certainly worth avoiding all the
avalanche of dependencies :-)

Bruno
-- 
In memoriam Hatun Sürücü <http://en.wikipedia.org/wiki/Hatun_Sürücü>



reply via email to

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