Fix posix_spawn getrlimit64 namespace (bug 17991)
Rich Felker
dalias@libc.org
Tue Feb 17 21:46:00 GMT 2015
On Tue, Feb 17, 2015 at 05:44:55PM +0000, Joseph Myers wrote:
> posix_spawn (a standard POSIX function) brings in a use of getrlimit64
> (not a standard POSIX function). This patch fixes this by using
> __getrlimit64 and making getrlimit64 a weak alias.
>
> This is more complicated than some such changes because of files that
> define getrlimit64 in their own way using symbol versioning after
> including the main sysdeps/unix/sysv/linux/getrlimit64.c with a
> getrlimit macro defined. There are various existing patterns for such
> cases in glibc; the one I've used here is that a getrlimit64 macro
> disables the weak_alias / libc_hidden_weak calls, leaving it to the
> including file to define the getrlimit64 name in whatever way is
> appropriate.
>
> Tested for x86_64 and x86 that installed stripped shared libraries are
> unchanged by this patch.
> [...]
> @@ -40,4 +40,6 @@ getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
>
> return 0;
> }
> -libc_hidden_def (getrlimit64)
> +libc_hidden_def (__getrlimit64)
> +weak_alias (__getrlimit64, getrlimit64)
> +libc_hidden_weak (getrlimit64)
> diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
> index 4a25c89..eee9331 100644
> --- a/sysdeps/posix/spawni.c
> +++ b/sysdeps/posix/spawni.c
> @@ -188,7 +188,7 @@ __spawni (pid_t *pid, const char *file,
> {
> if (! have_fdlimit)
> {
> - getrlimit64 (RLIMIT_NOFILE, &fdlimit);
> + __getrlimit64 (RLIMIT_NOFILE, &fdlimit);
> have_fdlimit = true;
> }
Wouldn't it make more sense to use sysconf() to get the limit?
Rich
More information about the Libc-alpha
mailing list