From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D81593858405; Mon, 10 Jan 2022 18:34:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D81593858405 From: "adhemerval.zanella at linaro dot org" To: glibc-bugs@sourceware.org Subject: [Bug libc/28730] Extend posix_spawnattr_* interface with more useful features Date: Mon, 10 Jan 2022 18:34:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: adhemerval.zanella at linaro dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2022 18:34:17 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28730 --- Comment #9 from Adhemerval Zanella --- (In reply to Florian Weimer from comment #7) > Adding a void * could increase alignment on some architectures, so we'd h= ave > to use a different mechanism for that. We can store a (potentially > unaligned) pointer field in the current padding and access it using memcp= y, > for example. >=20 > We should definitely not change the struct size to implement this. That's why I wrote on a previous comment: > The only issue would be to add the newer pointers fields without changing= =20 > posix_spawnattr_t, since the internal fields alignment might require to u= se a=20 > different value for the __pad size. Since we can't use offsetof on spawn.h (since it will be a namespace violation),=20 I think it would be better to use something similar to what we do already f= or=20 some pthread structs: #define __SIZEOF_POSIX_SPAWNATTR_T 336 typedef struct { char __size[__SIZEOF_POSIX_SPAWNATTR_T]; long int __align; } posix_spawnattr_t; The __SIZEOF_POSIX_SPAWNATTR_T will need to be arch-specific since m68k aligment=20 oddity makes the posix_spawnattr_t size 332 instead. Then internally we will have: struct posix_spawnattr {=20 short int __flags; pid_t __pgrp; sigset_t __sd; sigset_t __ss; struct sched_param __sp; int __policy; int __deathsignal; char *__procname; void *__resource; void *__extension; }; _Static_assert (sizeof (struct posix_spawnattr) <=3D sizeof (posix_spawnattr_t), "sizeof (struct posix_spawnattr) > sizeof (posix_spawnattr_t)"); Once the _Static_assert starts to fail we will need use '__extension'. > The closer one looks.. :-) we should do it like QNX does.. >=20 > int posix_spawnattr_setstackmax( > posix_spawnattr_t *attrp, > a_reasonable_non_lfs_dependant_type (uint64_t?) size); >=20 > sets RLIMIT_STACK. _setfilemax() or similar sets NOFILE..and so on..onl= y add > those that are useful in many cases.. unfortunately this is the onl= y sane way > I see forward, it makes the interface even more annoyingly ver= bose but IMHO we > shouldn't make this functions to take LFS dependant type= s at all. I am not very found of adding one interface to each resource, since we alre= ady have a current map to it (used by getrlimit/setrlimit/prlimit). Also using= =20 uint64_t is not possible due name polution (so we will need to either create a new type, or have different prototypes depending of the wordsize), and=20 we will need to map all current rlimit members (POSIX states the minimum member, so any new member would require a new symbol). And taking in consideration that LFS is deprecated and that we already added newer interfaces that are LFS-only (getdents64), I think int posix_spawnattr_setrlimit_np (posix_spawnattr_t *attrp, int resource,= =20 const struct rlimit64 *rlim); makes even more sense. --=20 You are receiving this mail because: You are on the CC list for the bug.=