[PATCH] posix: Add posix_spawn extension to setup resource limits (BZ 31049)

Florian Weimer fweimer@redhat.com
Fri Jun 6 06:44:30 GMT 2025


* Adhemerval Zanella:

> This patch adds two new functions:
>
>   int posix_spawnattr_setrlimit_np (posix_spawnattr_t *restrict __attr,
>  				    int resource,
>                                     const struct rlimit *rlim);
>
>   int posix_spawnattr_getrlimit_np (posix_spawnattr_t *__restrict __attr,
>                                     int resource,
>                                     struct rlimit *rlim)
>
> Along with a new POSIX_SPAWN_SETRLIMIT flag.  It allows to setup the
> new process resource limits, similar to call setlimit/prlimit before
> execve.  It work for both posix_spawn and pidfd_spawn.

Why is the separate flag is needed?

> The resources limits are applied after the effective user and group IDs
> change (POSIX_SPAWN_RESETIDS) and before the file actions.  Only LFS
> supported is provided (non-LFS prototypes are not exported or
> implemented).

It would be more general to treat this as a file action, so that the
limits can be applied after opening files.

Thanks,
Florian



More information about the Libc-alpha mailing list