From patchwork Mon Jul 19 21:47:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 44426 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 394993971C14 for ; Mon, 19 Jul 2021 21:48:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1]) by sourceware.org (Postfix) with ESMTPS id F2B3C396EC88 for ; Mon, 19 Jul 2021 21:47:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F2B3C396EC88 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 4F0DD65F; Mon, 19 Jul 2021 23:47:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sVFXWDl-58wX; Mon, 19 Jul 2021 23:47:51 +0200 (CEST) Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 4648763F; Mon, 19 Jul 2021 23:47:51 +0200 (CEST) Received: from samy by begin with local (Exim 4.94.2) (envelope-from ) id 1m5b78-006jgJ-DS; Mon, 19 Jul 2021 23:47:50 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited] hurd: Add support for spawn_do_closefrom Date: Mon, 19 Jul 2021 23:47:50 +0200 Message-Id: <20210719214750.1605524-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spamd-Bar: ++ X-Rspamd-Server: hera Authentication-Results: hera.aquilenet.fr X-Rspamd-Queue-Id: 4F0DD65F X-Spamd-Result: default: False [2.50 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; BAYES_HAM(-2.50)[97.76%] X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- sysdeps/mach/hurd/spawn_int_def.h | 24 ++++++++++++++++++++++++ sysdeps/mach/hurd/spawni.c | 15 ++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 sysdeps/mach/hurd/spawn_int_def.h diff --git a/sysdeps/mach/hurd/spawn_int_def.h b/sysdeps/mach/hurd/spawn_int_def.h new file mode 100644 index 0000000000..d04a416986 --- /dev/null +++ b/sysdeps/mach/hurd/spawn_int_def.h @@ -0,0 +1,24 @@ +/* Internal definitions for posix_spawn functionality. Hurd version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SPAWN_INT_DEF_H +#define _SPAWN_INT_DEF_H + +#define __SPAWN_SUPPORT_CLOSEFROM 1 + +#endif /* _SPAWN_INT_H */ diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c index e011c3b34b..060e389bbb 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/spawni.c @@ -505,6 +505,19 @@ retry: return EBADF; } + /* Close file descriptors in the child. */ + error_t do_closefrom (int lowfd) + { + while ((unsigned int) lowfd < dtablesize) + { + error_t err = do_close (lowfd); + if (err != 0 && err != EBADF) + return err; + lowfd++; + } + return 0; + } + /* Make sure the dtable can hold NEWFD. */ #define EXPAND_DTABLE(newfd) \ ({ \ @@ -615,7 +628,7 @@ retry: break; case spawn_do_closefrom: - err = EINVAL; + err = do_closefrom (action->action.closefrom_action.from); break; }