From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19149 invoked from network); 15 Nov 2023 22:39:07 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 15 Nov 2023 22:39:07 -0000 Received: (qmail 15771 invoked by uid 550); 15 Nov 2023 22:39:05 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 15728 invoked from network); 15 Nov 2023 22:39:04 -0000 Date: Wed, 15 Nov 2023 17:39:03 -0500 From: Rich Felker To: Tavian Barnes Cc: musl@lists.openwall.com Message-ID: <20231115223902.GY4163@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Feature request: posix_spawnattr_setrlimit_np() On Wed, Nov 15, 2023 at 05:00:51PM -0500, Tavian Barnes wrote: > I have a program that raises its soft RLIMIT_NOFILE, but wants to > spawn processes with the original value (in case they use select(), > for example). There seems to be no nice way to do this with > posix_spawn(). I can temporarily lower the rlimit in the parent, but > that interferes with other threads, and can make posix_spawn() fail > with EMFILE. > > Corresponding glibc feature request: > https://sourceware.org/bugzilla/show_bug.cgi?id=31049 I don't have any objection to this as long as it's coordinated and there's agreement from other implementors, but there *is* a way to do it already. You posix_spawnp: sh -c 'ulimit -n whatever && exec "$0" "$@"' your_program args... This is the general solution to doing all sorts of "child process state setup" things that posix_spawn doesn't have a dedicated attribute for. Note that for a proposal for setting rlimits via an attribute, one complication that needs to be specified is whether the limits take place before or after file actions, since they could change the outcome of file actions. I'm not sure what the answer is, but just YOLO'ing an implementation without thinking about that is a bad idea. Rich