From patchwork Sun Jul 28 19:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1965742 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iK4dJgAR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WX9rq6NZFz1ybY for ; Mon, 29 Jul 2024 05:04:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F0423858289 for ; Sun, 28 Jul 2024 19:04:10 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 5D8B13858417 for ; Sun, 28 Jul 2024 19:02:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D8B13858417 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5D8B13858417 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722193377; cv=none; b=VzA/3Nyr2hP+CgPkEbMMZVLsdoG1Hoa+iRrguwI5aCTPjJgd136lvV5+Pyokzollkn4tre8kN5+Hi92YJCoeb+EOkrCUXP161FJ4B3HZAbk5cIVmASibZqsrY5Hg6aecTHXQEaJOp+ebR5sJVx6lSYpo2RqHrCsfqpDeN3N9TlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722193377; c=relaxed/simple; bh=FybevqZpXWgIdeyTpIylMgJljsEULH4XZaOUhiHho6Q=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=b4UqakbIjsCqIIGadLdqK9P4QsXSBHs4qAwmnQt2Ybr+fkbtTN7OiMbeBPCIETYgkuwwJwdkRzKkCG0OE/eHWcU7KstnpAP2QJGOz4qiY8JWaSKyfdmmImHxk5IAV2qiGmiZgvSRohH5ukcZ88TOfgi9ZStzeggsoITuFrVwo6Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722193375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tvZDkF6QorHesoQXlXfReQwLcsFEV0Cax0jsqurioSY=; b=iK4dJgARPhTupXmIFrxHuXvcost0NtR4a9cURZrDJ6mOjtCdbIZZ9OqTwLdlw+peJcIKqD en4Bv4x/13mbqaLTAAlGX7HfVrF9+lDWo6003oI1U5zzbnHLCjSa5pKk6nA00am1/mw6zA x+vKiAvEOFrgjXKG1dS0d4b08vgiS6E= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-35-REWkVU0kOyCSHypBGqt1vQ-1; Sun, 28 Jul 2024 15:02:53 -0400 X-MC-Unique: REWkVU0kOyCSHypBGqt1vQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 763A6195609F for ; Sun, 28 Jul 2024 19:02:52 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.45.224.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C7671955D42 for ; Sun, 28 Jul 2024 19:02:51 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v2 06/13] posix: Introduce the __arch_spawni function In-Reply-To: Message-ID: <465f313f9ae9e74fd610ca63f4afc02992ce68c0.1722193092.git.fweimer@redhat.com> References: X-From-Line: 465f313f9ae9e74fd610ca63f4afc02992ce68c0 Mon Sep 17 00:00:00 2001 Date: Sun, 28 Jul 2024 21:02:48 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org And move the definition of SPAWN_ERROR to spawn_int.h. The separate __arch_spawni function allows centralized implementation of preparatory code in posix/spawni.c, which is no longer a stub after this commit. --- posix/spawn_int.h | 7 +++++ posix/spawni.c | 15 ++--------- sysdeps/generic/arch-spawni.h | 27 +++++++++++++++++++ sysdeps/mach/hurd/{spawni.c => arch-spawni.h} | 12 ++++----- .../sysv/linux/{spawni.c => arch-spawni.h} | 18 ++++--------- 5 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 sysdeps/generic/arch-spawni.h rename sysdeps/mach/hurd/{spawni.c => arch-spawni.h} (99%) rename sysdeps/unix/sysv/linux/{spawni.c => arch-spawni.h} (96%) diff --git a/posix/spawn_int.h b/posix/spawn_int.h index 2cdb55b4d6..9d0de483fe 100644 --- a/posix/spawn_int.h +++ b/posix/spawn_int.h @@ -78,6 +78,13 @@ struct __spawn_action #define SPAWN_XFLAGS_TRY_SHELL 0x2 #define SPAWN_XFLAGS_RET_PIDFD 0x4 +/* The Unix standard contains a long explanation of the way to signal + an error after the fork() was successful. Since no new wait status + was wanted there is no way to signal an error using one of the + available methods. The committee chose to signal an error by a + normal program exit with the exit code 127. */ +#define SPAWN_ERROR 127 + extern int __posix_spawn_file_actions_realloc (posix_spawn_file_actions_t * file_actions) attribute_hidden; diff --git a/posix/spawni.c b/posix/spawni.c index 52ff5f1966..ef47dd9ea4 100644 --- a/posix/spawni.c +++ b/posix/spawni.c @@ -19,15 +19,7 @@ #include #include #include "spawn_int.h" - - -/* The Unix standard contains a long explanation of the way to signal - an error after the fork() was successful. Since no new wait status - was wanted there is no way to signal an error using one of the - available methods. The committee chose to signal an error by a - normal program exit with the exit code 127. */ -#define SPAWN_ERROR 127 - +#include /* Spawn a new process executing PATH with the attributes describes in *ATTRP. Before running the process perform the actions described in FILE-ACTIONS. */ @@ -37,8 +29,5 @@ __spawni (pid_t *pid, const char *file, const posix_spawnattr_t *attrp, char *const argv[], char *const envp[], int xflags) { - __set_errno (ENOSYS); - return -1; + return __arch_spawni (pid, file, file_actions, attrp, argv, envp, xflags); } - -stub_warning (__spawni) diff --git a/sysdeps/generic/arch-spawni.h b/sysdeps/generic/arch-spawni.h new file mode 100644 index 0000000000..ad225d642d --- /dev/null +++ b/sysdeps/generic/arch-spawni.h @@ -0,0 +1,27 @@ +/* Architecture-specific __spawni implementation. Stub version. + Copyright (C) 2024 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 + . */ + +static int +__arch_spawni (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, char *const argv[], + char *const envp[], int xflags) +{ + __set_errno (ENOSYS); + return -1; +} diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/arch-spawni.h similarity index 99% rename from sysdeps/mach/hurd/spawni.c rename to sysdeps/mach/hurd/arch-spawni.h index a0d2e28c8e..6c1b9e98ad 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/arch-spawni.h @@ -36,12 +36,12 @@ /* Spawn a new process executing PATH with the attributes describes in *ATTRP. Before running the process perform the actions described in FILE-ACTIONS. */ -int -__spawni (pid_t *pid, const char *file, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, - char *const argv[], char *const envp[], - int xflags) +static int +__arch_spawni (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[], + int xflags) { pid_t new_pid; char *path, *p, *name; diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/arch-spawni.h similarity index 96% rename from sysdeps/unix/sysv/linux/spawni.c rename to sysdeps/unix/sysv/linux/arch-spawni.h index f57e92815e..8caf74f7f5 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/arch-spawni.h @@ -47,14 +47,6 @@ child has either exec'ed successfully or exited. */ -/* The Unix standard contains a long explanation of the way to signal - an error after the fork() was successful. Since no new wait status - was wanted there is no way to signal an error using one of the - available methods. The committee chose to signal an error by a - normal program exit with the exit code 127. */ -#define SPAWN_ERROR 127 - - struct posix_spawn_args { internal_sigset_t oldmask; @@ -483,11 +475,11 @@ __spawnix (int *pid, const char *file, /* Spawn a new process executing PATH with the attributes describes in *ATTRP. Before running the process perform the actions described in FILE-ACTIONS. */ -int -__spawni (pid_t * pid, const char *file, - const posix_spawn_file_actions_t * acts, - const posix_spawnattr_t * attrp, char *const argv[], - char *const envp[], int xflags) +static int +__arch_spawni (pid_t * pid, const char *file, + const posix_spawn_file_actions_t * acts, + const posix_spawnattr_t * attrp, char *const argv[], + char *const envp[], int xflags) { /* It uses __execvpex to avoid run ENOEXEC in non compatibility mode (it will be handled by maybe_script_execute). */