From unknown Wed Jun 18 23:00:04 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#52835 <52835@debbugs.gnu.org> To: bug#52835 <52835@debbugs.gnu.org> Subject: Status: [PATCH 0/2] Fix spawning a child not setting standard fds properly Reply-To: bug#52835 <52835@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:00:04 +0000 retitle 52835 [PATCH 0/2] Fix spawning a child not setting standard fds pro= perly reassign 52835 guile submitter 52835 Josselin Poiret severity 52835 normal tag 52835 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 27 16:26:34 2021 Received: (at submit) by debbugs.gnu.org; 27 Dec 2021 21:26:34 +0000 Received: from localhost ([127.0.0.1]:44442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1xVq-0005dz-7B for submit@debbugs.gnu.org; Mon, 27 Dec 2021 16:26:34 -0500 Received: from lists.gnu.org ([209.51.188.17]:58184) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1xVn-0005dr-S7 for submit@debbugs.gnu.org; Mon, 27 Dec 2021 16:26:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xVn-000757-NE for bug-guile@gnu.org; Mon, 27 Dec 2021 16:26:31 -0500 Received: from jpoiret.xyz ([206.189.101.64]:40796) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xVm-0003dE-1I for bug-guile@gnu.org; Mon, 27 Dec 2021 16:26:31 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 23772184F6A; Mon, 27 Dec 2021 21:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1640640386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tQV4z7gWBGvaEEPcCfEXb+ERJ0AgQfAUqWo1DahSqOU=; b=dQvyzSo6OBWgrZEi7Z0wsWSYiSQ/rY0rz97S7y29ohNVpnGr8r9dNrzJR+CwhWN5qv5afz popyTJ44PXJyvD/X7c1eGno6jlB0Te2wx5WXI01dopvNScdeCCORB/S+SLBqxw+uwLPTCg fUbdeDbIV1BqDPKLxs1fDcfeSXuzLmHVTEWUbAaH3iYgv+9mssk+LVyS6r93gdgKGMVpaw Y3hHxS7KnaURqD3JCZNsjHPT9fGeMH2A7SznmK4q5X3W1Gkno8cOGjyDqoeUomp6onZHhF usqesdtp+pXgVhApV4xV1aCcxvywUW5cv3Tx3jyXorqAZCiKiw17g85MKVvarw== From: Josselin Poiret To: bug-guile@gnu.org Subject: [PATCH 0/2] Fix spawning a child not setting standard fds properly Date: Mon, 27 Dec 2021 22:25:56 +0100 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: ++++ Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Level: **** Received-SPF: pass client-ip=206.189.101.64; envelope-from=dev@jpoiret.xyz; helo=jpoiret.xyz X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.498, FROM_SUSPICIOUS_NTLD_FP=0.001, PDS_OTHER_BAD_TLD=1.997, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.6 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello, While working on the Guix installer (that needs to use system* quite a lot), I've noticed that output/error redirection doesn't behave as intended when combined with system*. Here's a test you can try [...] Content analysis details: (1.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.9 SPF_FAIL SPF: sender does not match SPF record (fail) [SPF failed: Please see http://www.openspf.org/Why?s=mfrom; id=dev%40jpoiret.xyz; ip=209.51.188.17; r=debbugs.gnu.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.51.188.17 listed in wl.mailspike.net] 0.5 FROM_SUSPICIOUS_NTLD_FP From abused NTLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Debbugs-Envelope-To: submit Cc: Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.1 (/) Hello, While working on the Guix installer (that needs to use system* quite a lot), I've noticed that output/error redirection doesn't behave as intended when combined with system*. Here's a test you can try at home: --8<---------------cut here---------------start------------->8--- (call-with-output-file "/tmp/test.log" (lambda (port) (with-output-to-port port (lambda () (with-error-to-port port (lambda () (system* "bash" "-c" "echo bong >&2"))))))) --8<---------------cut here---------------end--------------->8--- With current Guix, you will notice that /tmp/test.log is empty, instead of the expected "bong". Worse even, when testing with --8<---------------cut here---------------start------------->8--- (with-error-to-port (current-output-port) (lambda () (system* "bash" "-c" "echo $$; sleep 10"))) --8<---------------cut here---------------end--------------->8--- you can actually inspect `/proc//fd/` and see that the stderr fd, 2, is actually closed. This means that the next opened fd will take its place, to which writes to stderr may end up. The logic behind the stdin/out/err redirection for child processes lies in `start_child`, in libguile/posix.c, and doesn't take into account cases like: * in/out/err having common values, as the common fd will be closed before it has been dup2'd to all the std fds (which happens in the first example); * in/out/err having values between 0 and 2 which aren't their corresponding std fd number, as they will not be dup2'd to the stdin/out/err (which happens in the second example). The first patch addresses this by: * moving in/out/err closing logic after they've all been dup2'd; * removing the check that in/out/err are > the corresponding stdin/out/err; * replacing renumber_file_descriptor by simply dup, as the former closes fds that might be shared. The closing logic of the first point is enough here. The second patch removes renumber_file_descriptor, as it is no longer used. Best, Josselin Josselin Poiret (2): Fix child spawning closing standard fds prematurely Remove unused renumber_file_descriptor libguile/posix.c | 72 ++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 52 deletions(-) -- 2.34.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 27 16:36:09 2021 Received: (at 52835) by debbugs.gnu.org; 27 Dec 2021 21:36:09 +0000 Received: from localhost ([127.0.0.1]:44450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1xf7-0005v3-6L for submit@debbugs.gnu.org; Mon, 27 Dec 2021 16:36:09 -0500 Received: from jpoiret.xyz ([206.189.101.64]:42894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1xf3-0005us-BQ for 52835@debbugs.gnu.org; Mon, 27 Dec 2021 16:36:08 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id E3879184F5B; Mon, 27 Dec 2021 21:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1640640964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ojPF/jO37wQEtTdoeOdj88gt6VBy/6zjvkMa4F5oTtk=; b=t+IJars5NA0A/M51qzJohD8TIqEJRm8a94YfIPGA3/wFrJ0otPQCyamodPLMGj6jhwM0lc 5qkgru+abIW1jmYUZc9ULnyREV6+8HyR/Un0IWJ6DaZVcGRI3tPXzfdxwtBKRHYOxYcX07 pC1aZ9HXpD3HmNY6K3zZvTD2Cm5ggiUBmfM3WBYXGd2Dfxg2ZUfcQtgQDFGgMhUMC54tm+ JuBlw9jNgMnm9kpwnCiQ43B0RUzgsgjI280to5zx+9gPi4WG2mhQ+9nGgy31rV3mXRHdso 8zsY/vABSuwd/VFYQmO1/Qezc3zuWuP/99lQtDj/aEFclcugN+6NPHdqb5XHyw== From: Josselin Poiret To: Josselin Poiret Subject: [PATCH 1/2] Fix child spawning closing standard fds prematurely Date: Mon, 27 Dec 2021 22:35:37 +0100 Message-Id: <299d40c7e9fc0c30c3aebfa06c69506b981bd1f8.1640638819.git.dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (start_child): Close standard file descriptors only after all of them have been dup2'd. --- libguile/posix.c | 40 +++++++++++++++++++ 1 file changed, 19 inserti [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (start_child): Close standard file descriptors only after all of them have been dup2'd. --- libguile/posix.c | 40 +++++++++++++++++++ 1 file changed, 19 inserti [...] Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * libguile/posix.c (start_child): Close standard file descriptors only after all of them have been dup2'd. --- libguile/posix.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 3ab12b99e..148ebeb3d 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1357,27 +1357,25 @@ start_child (const char *exec_file, char **exec_argv, if (err == -1) err = open ("/dev/null", O_WRONLY); - if (in > 0) - { - if (out == 0) - out = renumber_file_descriptor (out, err); - if (err == 0) - err = renumber_file_descriptor (err, err); - do dup2 (in, 0); while (errno == EINTR); - close (in); - } - if (out > 1) - { - if (err == 1) - err = renumber_file_descriptor (err, err); - do dup2 (out, 1); while (errno == EINTR); - close (out); - } - if (err > 2) - { - do dup2 (err, 2); while (errno == EINTR); - close (err); - } + /* Dup each non-yet-dup2'd fd that's in the way to the next available fd, + so that we can safely dup2 to 0/1/2 without potentially overwriting + in/out/err. Note that dup2 doesn't do anything if its arguments are + equal. */ + if (out == 0) + do out = dup (out); while (errno == EINTR); + if (err == 0) + do err = dup (err); while (errno == EINTR); + do dup2 (in, 0); while (errno == EINTR); + + if (err == 1) + do err = dup (err); while (errno == EINTR); + do dup2 (out, 1); while (errno == EINTR); + + do dup2 (err, 2); while (errno == EINTR); + + if (in > 2) close (in); + if (out > 2) close (out); + if (err > 2) close (err); execvp (exec_file, exec_argv); -- 2.34.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 27 16:36:13 2021 Received: (at 52835) by debbugs.gnu.org; 27 Dec 2021 21:36:13 +0000 Received: from localhost ([127.0.0.1]:44454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1xfB-0005vS-Ef for submit@debbugs.gnu.org; Mon, 27 Dec 2021 16:36:13 -0500 Received: from jpoiret.xyz ([206.189.101.64]:42954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1xf9-0005vI-Lc for 52835@debbugs.gnu.org; Mon, 27 Dec 2021 16:36:12 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id DB979184F5B; Mon, 27 Dec 2021 21:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1640640971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tutqoZK5dGsiptfltkjprHmdq7vFTSOG3/AwqU/vgOY=; b=h5+Sk0dnOw/FJ3dOWzPXwMsExcpeQPc8Ae137xLTzpMDAH1z04cPDDUX7N1+hGwC+YdCSi EzLzHGH6y8S7GIvypD9+VwfXCfjdm0G1Ir1T/POy9O3eiYgE84Ywdrb2KA0t+1v0WdToI+ EX7oKInJWjEWP81n5/m27Ipe8RTT03iOzmDJe78QUQ6Xw8AQf5Voi/TdhPBXrNbMOLvJLA wR6KYGHPRnh7i6s0G3OeQP8aJt+ta8Fupq0wMR/6bLRB2MEBgs9J7h7XmetdM/XdlPnX3I wZILI8bV95yxcCGJxPj8E5194wuP5t7H3fG6QtVdcnb9ZV/D/x1W2E+HxlYxuQ== From: Josselin Poiret To: Josselin Poiret Subject: [PATCH 2/2] Remove unused renumber_file_descriptor Date: Mon, 27 Dec 2021 22:35:38 +0100 Message-Id: <552de70f16142c8a42cde0a449549eac42e48485.1640638819.git.dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor): Remove it. --- libguile/posix.c | 32 + 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 148ebeb3d..2624d07c2 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1277,37 +1277,7 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor): Remove it. --- libguile/posix.c | 32 + 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 148ebeb3d..2624d07c2 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1277,37 +1277,7 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, [...] Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * libguile/posix.c (renumber_file_descriptor): Remove it. --- libguile/posix.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 148ebeb3d..2624d07c2 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1277,37 +1277,7 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, return scm_from_int (pid); } #undef FUNC_NAME -#endif /* HAVE_FORK */ - -#ifdef HAVE_FORK -/* 'renumber_file_descriptor' is a helper function for 'start_child' - below, and is specialized for that particular environment where it - doesn't make sense to report errors via exceptions. It uses dup(2) - to duplicate the file descriptor FD, closes the original FD, and - returns the new descriptor. If dup(2) fails, print an error message - to ERR and abort. */ -static int -renumber_file_descriptor (int fd, int err) -{ - int new_fd; - - do - new_fd = dup (fd); - while (new_fd == -1 && errno == EINTR); - - if (new_fd == -1) - { - /* At this point we are in the child process before exec. We - cannot safely raise an exception in this environment. */ - const char *msg = strerror (errno); - fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); - _exit (127); /* Use exit status 127, as with other exec errors. */ - } - - close (fd); - return new_fd; -} -#endif /* HAVE_FORK */ +#endif /* HAVE_FORK * #ifdef HAVE_FORK #define HAVE_START_CHILD 1 -- 2.34.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 27 16:50:07 2021 Received: (at 52835) by debbugs.gnu.org; 27 Dec 2021 21:50:07 +0000 Received: from localhost ([127.0.0.1]:44479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1xsc-0006LX-Px for submit@debbugs.gnu.org; Mon, 27 Dec 2021 16:50:06 -0500 Received: from jpoiret.xyz ([206.189.101.64]:43738) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1xsa-0006LL-My for 52835@debbugs.gnu.org; Mon, 27 Dec 2021 16:50:05 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 01BE8184F5B; Mon, 27 Dec 2021 21:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1640641803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qMe6KAudtvA5vNnkI+Rkl+ZhPAPII95GLnzT30kKsyw=; b=XgH1BkmJSyxEpLKsFzM9hL0Pp/2gbG+8gjAMQYnlNcHBCgdDmM04bfaWxg5bhIp9t+1wd5 34YC1CTmdeRpw2g+qlG08ozjt0kPk+T7PaJGNWgwGmqM50PYASJwuezMA3nLo+2MC/R3tr BgtXdm9Xgqv/B+Qivwm96kN0kdCdXaPeTdJ5QAhSiy6npt6MGKC+Uw8JCotKxF9ytG8CT5 Hzhlg74if7Zxdn2KKbqv3UrABdSIPKiGqHdjbpi5nIokz36m1SXeu//cwLtgmGGFSvpTjG Oq0NaxhrrIA1aSCXEdYbhcTRzAbilpfReE7+0lzS/cnzRCTnrpdX5Ry6F+PFnw== From: Josselin Poiret To: Josselin Poiret Subject: [PATCH v2 2/2] Remove unused renumber_file_descriptor Date: Mon, 27 Dec 2021 22:49:59 +0100 Message-Id: <20211227214959.15324-1-dev@jpoiret.xyz> In-Reply-To: <552de70f16142c8a42cde0a449549eac42e48485.1640638819.git.dev@jpoiret.xyz> References: <552de70f16142c8a42cde0a449549eac42e48485.1640638819.git.dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor): Remove it. --- Sorry for the noise, but I just saw that this patch omitted a closing */, here is a fixed version. libguile/posix.c | 30 1 file changed, 30 deletions(-) Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor): Remove it. --- Sorry for the noise, but I just saw that this patch omitted a closing */, here is a fixed version. libguile/posix.c | 30 1 file changed, 30 deletions(-) Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * libguile/posix.c (renumber_file_descriptor): Remove it. --- Sorry for the noise, but I just saw that this patch omitted a closing */, here is a fixed version. libguile/posix.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 148ebeb3d..1d9996565 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1279,36 +1279,6 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #undef FUNC_NAME #endif /* HAVE_FORK */ -#ifdef HAVE_FORK -/* 'renumber_file_descriptor' is a helper function for 'start_child' - below, and is specialized for that particular environment where it - doesn't make sense to report errors via exceptions. It uses dup(2) - to duplicate the file descriptor FD, closes the original FD, and - returns the new descriptor. If dup(2) fails, print an error message - to ERR and abort. */ -static int -renumber_file_descriptor (int fd, int err) -{ - int new_fd; - - do - new_fd = dup (fd); - while (new_fd == -1 && errno == EINTR); - - if (new_fd == -1) - { - /* At this point we are in the child process before exec. We - cannot safely raise an exception in this environment. */ - const char *msg = strerror (errno); - fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); - _exit (127); /* Use exit status 127, as with other exec errors. */ - } - - close (fd); - return new_fd; -} -#endif /* HAVE_FORK */ - #ifdef HAVE_FORK #define HAVE_START_CHILD 1 /* Since Guile uses threads, we have to be very careful to avoid calling -- 2.34.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 10:40:09 2021 Received: (at submit) by debbugs.gnu.org; 28 Dec 2021 15:40:09 +0000 Received: from localhost ([127.0.0.1]:47231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2Ea9-00011S-0e for submit@debbugs.gnu.org; Tue, 28 Dec 2021 10:40:09 -0500 Received: from lists.gnu.org ([209.51.188.17]:60140) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2Ea7-00011K-P3 for submit@debbugs.gnu.org; Tue, 28 Dec 2021 10:40:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2Ea7-0004IE-Df for bug-guile@gnu.org; Tue, 28 Dec 2021 10:40:07 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:40913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2Ea5-0003r7-JC for bug-guile@gnu.org; Tue, 28 Dec 2021 10:40:07 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8266A5C00CD; Tue, 28 Dec 2021 10:40:04 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 28 Dec 2021 10:40:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=lIF3z0naPvDBZ9w4r7sWK8ciDzQrONkqpl6lfHuZi vE=; b=F1NR5BDe7s8V2lHXFc90lxCqZqTv3mUZRxYFhnpNEVi3/DqURqCA702IN 7ljHfMhtBldX/3y49xnIHIC8jLeLsYHfQNcbWvShKazbwoDtJ2YSsa1xpQHHIY33 dFUO0fL8inFZi9eFDt5lpbl+5Cb8FJ5uZHTRYE2gSJNaZRtVy5WEdXM+tMGU0hPR 7uX6hlpz8OaZIbVQDmywSfdpNn/UtghuaTX9Rxm4qU1Dv4rXIW1OCRJTbRm0QVFW 9MXAyEl1c4e3LlnO1K70u31gxVq9uulgmcqygszrn6iFmIXQ1/7imRnM6FatCoVN WmQezyecWuxgULCC+5/awKKPGXgfg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrudduledgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufhfffgjkfgfgggtgfesthhqredttderjeenucfhrhhomhepvfhimhho thhhhicuufgrmhhplhgvuceoshgrmhhplhgvthesnhhghihrohdrtghomheqnecuggftrf grthhtvghrnhepffdtveefgefhhfevhffhhfegfefffeegtdekfeekgeejveffvdehhedv gfettdfgnecuffhomhgrihhnpehophgvnhhgrhhouhhprdhorhhgnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhplhgvthesnhhghihr ohdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 28 Dec 2021 10:40:03 -0500 (EST) From: Timothy Sample To: Josselin Poiret via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: Date: Tue, 28 Dec 2021 10:40:02 -0500 In-Reply-To: (Josselin Poiret via's message of "Mon, 27 Dec 2021 22:25:56 +0100") Message-ID: <8735mcu4a5.fsf@ngyro.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=66.111.4.27; envelope-from=samplet@ngyro.com; helo=out3-smtp.messagingengine.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.7 (-) X-Debbugs-Envelope-To: submit Cc: 52835@debbugs.gnu.org, Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.7 (--) Hey Josselin, Thanks for finding this bug! I have one concern about your patches: Josselin Poiret writes: > The second patch removes renumber_file_descriptor, as it is no longer > used. One thing that =E2=80=98renumber_file_descriptor=E2=80=99 does that we seem= to be losing here is error checking. To my eye, the old code will try and warn the user if they run out of file descriptors, but the new code will not. The other thing that I like is how =E2=80=98renumber_file_descriptor=E2=80= =99 checks the return value of =E2=80=98dup=E2=80=99 in addition to checking =E2=80=98errn= o=E2=80=99. (I realize that the old code skips that check for =E2=80=98dup2=E2=80=99 =E2=80=93 I=E2=80= =99m kinda just stating a preference here.) A quick check of POSIX turns up the following: =E2=80=9C= the value of =E2=80=98errno=E2=80=99 should only be examined when it is indicat= ed to be valid by a function=E2=80=99s return value=E2=80=9D [1]. -- Tim [1] https://pubs.opengroup.org/onlinepubs/9699919799/ From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 12:25:08 2021 Received: (at 52835) by debbugs.gnu.org; 28 Dec 2021 17:25:08 +0000 Received: from localhost ([127.0.0.1]:47324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2GDk-0003c0-HW for submit@debbugs.gnu.org; Tue, 28 Dec 2021 12:25:08 -0500 Received: from jpoiret.xyz ([206.189.101.64]:41796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2GDi-0003bp-Uu for 52835@debbugs.gnu.org; Tue, 28 Dec 2021 12:25:07 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id B7A51184CCF; Tue, 28 Dec 2021 17:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1640712305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g38hw+70E2/b7MCh5o9fyLFdhX8ue4AGYsqBWCz6rmE=; b=hccswQshMGiCzSlQmHZP8bXyt97J2alkR9ST2Rdm6EB8LwnKtjWt9jHheUOMVADmVLgkT4 nBgi81DwuVgHGDE60svg/oO36D6l/u8Zbp2d/8zlnccjc2PxffBKYx0cAO/PzEVOvrhfVp 3TOSfGZ5bshbvBKxzNsKn4xbpIKwxKWcH45N+QpzFKxuberIztWnr9EByFdSfP7+NRpd65 YCF8UMkL3joAuTRYTrafzC+oZ6PLRo8XDUeN9l9oSlCTZRsqyku43Jo+9JtLvfWebGtU7B aV4CbozRjQg0mxrV8QGcJrlryfJ1I+xFYuJ7Vpe6woaKBZsef4uHbSahCMfqiA== From: Josselin Poiret To: Timothy Sample Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly In-Reply-To: <8735mcu4a5.fsf@ngyro.com> References: <8735mcu4a5.fsf@ngyro.com> Date: Tue, 28 Dec 2021 18:25:03 +0100 Message-ID: <87lf04fxqo.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello Timothy, Timothy Sample writes: > One thing that ‘renumber_file_descriptor’ does that we seem to be losing > here is error checking. To my eye, the old code will try and warn the > user if they run out of file descriptors, but t [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello Timothy, Timothy Sample writes: > One thing that ‘renumber_file_descriptor’ does that we seem to be losing > here is error checking. To my eye, the old code will try and warn the > user if they run out of file descriptors, but t [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager Hello Timothy, Timothy Sample writes: > One thing that =E2=80=98renumber_file_descriptor=E2=80=99 does that we se= em to be losing > here is error checking. To my eye, the old code will try and warn the > user if they run out of file descriptors, but the new code will not. I may have been too hasty on that front, you're right that we should check for errors when dup'ing. Note though that we should not run out of fds, as we close all of them except for in/out/err right before using it, but still, here are the interesting error codes: * EINTR, although OpenBSD and Linux will never set that error from my light research; * EBUSY, not POSIX though, only Linux, so should we? * EMFILE, if we run out of fds; * EBADF if either of the fds are invalid. As for error reporting, should we keep the parent's stderr fd open while we do all of this, just to be able to report an error in case it happens? The old code used to try reporting the errors to the new `err` fd instead, but it might be clearer to use stderr. WDYT? --=20 Josselin Poiret From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 07 11:55:55 2022 Received: (at 52835) by debbugs.gnu.org; 7 Feb 2022 16:55:55 +0000 Received: from localhost ([127.0.0.1]:43604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nH7Ix-0003Ub-0I for submit@debbugs.gnu.org; Mon, 07 Feb 2022 11:55:55 -0500 Received: from jpoiret.xyz ([206.189.101.64]:46344) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nH7Iu-0003US-VQ for 52835@debbugs.gnu.org; Mon, 07 Feb 2022 11:55:53 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id C26641851ED; Mon, 7 Feb 2022 16:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1644252951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4kVbElNHtrKjq7eNd+6kpfceo5oRwkjPZqJ+p/QF4mA=; b=fmN3PGoIbN5c8mk+QF90EI4KgzT+tB+bRk6bmu84G89qQPb849DGegQ8d+HX8/5l/mvQi5 eEoRLwO8PYeYq+qB/brA1BuT05yOACxY6YCDg4xVjH8LODL0hEcruIQBhRAtt5sqOtORpJ B+axU7KgC+GxDip3G0EKluYnlI9vaObqZI7rAEVAfzzVlZD+gV/T/pRJ2Z/qhn0d8wm94t NYuTNwvU/mNha8Ser9frSKk+xCa1sAEHpZ+1jnbMpG0xd1FjHdoEIQFlrO+0556JzMLZcU 7SbedKWSNo3/3P+beSROvh7AwyLaJ081Jnavbm8RESbw9/a82LAGy4iC2eFUyw== From: Josselin Poiret To: Josselin Poiret , Timothy Sample Subject: [PATCH v3] Fix child spawning closing standard fds prematurely Date: Mon, 7 Feb 2022 17:55:43 +0100 Message-Id: <20220207165543.12723-1-dev@jpoiret.xyz> In-Reply-To: <87lf04fxqo.fsf@jpoiret.xyz> References: <87lf04fxqo.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Level: **** X-Spamd-Bar: ++++ X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor): Refactor it as dup_handle_error. (dup_handle_error, dup2_handle_error): New functions that wrap around dup and dup2 by retrying on EINTR or EBUSY, as wel [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor): Refactor it as dup_handle_error. (dup_handle_error, dup2_handle_error): New functions that wrap around dup and dup2 by retrying on EINTR or EBUSY, as wel [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * libguile/posix.c (renumber_file_descriptor): Refactor it as dup_handle_error. (dup_handle_error, dup2_handle_error): New functions that wrap around dup and dup2 by retrying on EINTR or EBUSY, as well as erroring out on other errors. (start_child): Close standard file descriptors only after all of them have been dup2'd. --- Hello, This is a new version of the fix that should now handle possible dup/dup2 errors properly. Best, Josselin libguile/posix.c | 82 +++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 3ab12b99e..dc3080b3c 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1280,14 +1280,14 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #endif /* HAVE_FORK */ #ifdef HAVE_FORK -/* 'renumber_file_descriptor' is a helper function for 'start_child' - below, and is specialized for that particular environment where it - doesn't make sense to report errors via exceptions. It uses dup(2) - to duplicate the file descriptor FD, closes the original FD, and - returns the new descriptor. If dup(2) fails, print an error message - to ERR and abort. */ +/* 'dup_handle_error' is a helper function for 'start_child' below, and + is specialized for that particular environment where it doesn't make + sense to report errors via exceptions. It uses dup(2) to duplicate + the file descriptor FD, does *not* close the original FD, and returns + the new descriptor. If dup(2) fails, print an error message to ERR + and abort. */ static int -renumber_file_descriptor (int fd, int err) +dup_handle_error (int fd, int err) { int new_fd; @@ -1304,7 +1304,33 @@ renumber_file_descriptor (int fd, int err) _exit (127); /* Use exit status 127, as with other exec errors. */ } - close (fd); + return new_fd; +} + +/* 'dup2_handle_error' is a helper function for 'start_child' below, and + is specialized for that particular environment where it doesn't make + sense to report errors via exceptions. It uses dup2(2) to duplicate + the file descriptor FD, does *not* close the original FD, and returns + the new descriptor. If dup2(2) fails, print an error message to ERR + and abort. */ +static int +dup2_handle_error (int fd, int to, int err) +{ + int new_fd; + + do + new_fd = dup2 (fd, to); + while (new_fd == -1 && (errno == EINTR || errno == EBUSY)); + + if (new_fd == -1) + { + /* At this point we are in the child process before exec. We + cannot safely raise an exception in this environment. */ + const char *msg = strerror (errno); + fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); + _exit (127); /* Use exit status 127, as with other exec errors. */ + } + return new_fd; } #endif /* HAVE_FORK */ @@ -1357,27 +1383,25 @@ start_child (const char *exec_file, char **exec_argv, if (err == -1) err = open ("/dev/null", O_WRONLY); - if (in > 0) - { - if (out == 0) - out = renumber_file_descriptor (out, err); - if (err == 0) - err = renumber_file_descriptor (err, err); - do dup2 (in, 0); while (errno == EINTR); - close (in); - } - if (out > 1) - { - if (err == 1) - err = renumber_file_descriptor (err, err); - do dup2 (out, 1); while (errno == EINTR); - close (out); - } - if (err > 2) - { - do dup2 (err, 2); while (errno == EINTR); - close (err); - } + /* Dup each non-yet-dup2'd fd that's in the way to the next available fd, + so that we can safely dup2 to 0/1/2 without potentially overwriting + in/out/err. Note that dup2 doesn't do anything if its arguments are + equal. */ + if (out == 0) + out = dup_handle_error (out, err); + if (err == 0) + err = dup_handle_error (err, err); + dup2_handle_error (in, 0, err); + + if (err == 1) + err = dup_handle_error (err, err); + dup2_handle_error (out, 1, err); + + dup2_handle_error (err, 2, err); + + if (in > 2) close (in); + if (out > 2) close (out); + if (err > 2) close (err); execvp (exec_file, exec_argv); -- 2.34.0 From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 08:46:58 2022 Received: (at 52835) by debbugs.gnu.org; 28 May 2022 12:46:58 +0000 Received: from localhost ([127.0.0.1]:36608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqL-0000zi-PP for submit@debbugs.gnu.org; Sat, 28 May 2022 08:46:58 -0400 Received: from jpoiret.xyz ([206.189.101.64]:34418) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqI-0000zL-3b for 52835@debbugs.gnu.org; Sat, 28 May 2022 08:46:55 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 1D372184F6B; Sat, 28 May 2022 12:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1653742013; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8m63TLUDs5+aH+MUdCMdFwxqTp48mqUGDe1QJLgZMwU=; b=eLQYquPNOUrHm3iPBwwXBhqiZGvjUL1dMclGGsFLktgCwPZXjQz8hy5Ij/sVMqqV0iN2ww mZeVQDTH9eETtN2yWBh9PAAzUjyZMtuMd6z2mV2cww25siL1tAa8BP/A8hJBAOtJQXfolQ 9yR/Q9e3s50w/RbGpI5W1hilnYjLlfP9MBE+v/pOu9fu2VTzBBvBq5vD6g33WIwvnqoXdC 8WovnLKoz1pn4V2fnVluizEvEBcJG61u/vmk/d7zI9c4Xr3LCOjWcg1tA7zJU/GtIXimFl QIafCI+H+P+tdztI1mSsxEAoaRepQDUPeniX93ETeKNPpV7b9mBiXlJ+1ZjMew== From: Josselin Poiret To: Josselin Poiret , Timothy Sample Subject: [PATCH v4 1/4] Fix child spawning closing standard fds prematurely. Date: Sat, 28 May 2022 14:46:31 +0200 Message-Id: <20220528124634.17353-2-dev@jpoiret.xyz> In-Reply-To: <20220528124634.17353-1-dev@jpoiret.xyz> References: <20220207165543.12723-1-dev@jpoiret.xyz> <20220528124634.17353-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor): Refactor it as dup_handle_error. (dup_handle_error, dup2_handle_error): New functions that wrap around dup and dup2 by retrying on EINTR or EBUSY, as wel [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor): Refactor it as dup_handle_error. (dup_handle_error, dup2_handle_error): New functions that wrap around dup and dup2 by retrying on EINTR or EBUSY, as wel [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * libguile/posix.c (renumber_file_descriptor): Refactor it as dup_handle_error. (dup_handle_error, dup2_handle_error): New functions that wrap around dup and dup2 by retrying on EINTR or EBUSY, as well as erroring out on other errors. (start_child): Close standard file descriptors only after all of them have been dup2'd. --- libguile/posix.c | 84 +++++++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 30 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 3ab12b99e..e9f49fa27 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1280,14 +1280,14 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #endif /* HAVE_FORK */ #ifdef HAVE_FORK -/* 'renumber_file_descriptor' is a helper function for 'start_child' - below, and is specialized for that particular environment where it - doesn't make sense to report errors via exceptions. It uses dup(2) - to duplicate the file descriptor FD, closes the original FD, and - returns the new descriptor. If dup(2) fails, print an error message - to ERR and abort. */ +/* 'dup_handle_error' is a helper function for 'start_child' below, and + is specialized for that particular environment where it doesn't make + sense to report errors via exceptions. It uses dup(2) to duplicate + the file descriptor FD, does *not* close the original FD, and returns + the new descriptor. If dup(2) fails, print an error message to ERR + and abort. */ static int -renumber_file_descriptor (int fd, int err) +dup_handle_error (int fd, int err) { int new_fd; @@ -1304,7 +1304,33 @@ renumber_file_descriptor (int fd, int err) _exit (127); /* Use exit status 127, as with other exec errors. */ } - close (fd); + return new_fd; +} + +/* 'dup2_handle_error' is a helper function for 'start_child' below, and + is specialized for that particular environment where it doesn't make + sense to report errors via exceptions. It uses dup2(2) to duplicate + the file descriptor FD, does *not* close the original FD, and returns + the new descriptor. If dup2(2) fails, print an error message to ERR + and abort. */ +static int +dup2_handle_error (int fd, int to, int err) +{ + int new_fd; + + do + new_fd = dup2 (fd, to); + while (new_fd == -1 && (errno == EINTR || errno == EBUSY)); + + if (new_fd == -1) + { + /* At this point we are in the child process before exec. We + cannot safely raise an exception in this environment. */ + const char *msg = strerror (errno); + fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); + _exit (127); /* Use exit status 127, as with other exec errors. */ + } + return new_fd; } #endif /* HAVE_FORK */ @@ -1357,34 +1383,32 @@ start_child (const char *exec_file, char **exec_argv, if (err == -1) err = open ("/dev/null", O_WRONLY); - if (in > 0) - { - if (out == 0) - out = renumber_file_descriptor (out, err); - if (err == 0) - err = renumber_file_descriptor (err, err); - do dup2 (in, 0); while (errno == EINTR); - close (in); - } - if (out > 1) - { - if (err == 1) - err = renumber_file_descriptor (err, err); - do dup2 (out, 1); while (errno == EINTR); - close (out); - } - if (err > 2) - { - do dup2 (err, 2); while (errno == EINTR); - close (err); - } + /* Dup each non-yet-dup2'd fd that's in the way to the next available fd, + so that we can safely dup2 to 0/1/2 without potentially overwriting + in/out/err. Note that dup2 doesn't do anything if its arguments are + equal. */ + if (out == 0) + out = dup_handle_error (out, err); + if (err == 0) + err = dup_handle_error (err, err); + dup2_handle_error (in, 0, err); + + if (err == 1) + err = dup_handle_error (err, err); + dup2_handle_error (out, 1, err); + + dup2_handle_error (err, 2, err); + + if (in > 2) close (in); + if (out > 2) close (out); + if (err > 2) close (err); execvp (exec_file, exec_argv); /* The exec failed! There is nothing sensible to do. */ { const char *msg = strerror (errno); - fprintf (fdopen (2, "a"), "In execvp of %s: %s\n", + dprintf (2, "In execvp of %s: %s\n", exec_file, msg); } -- 2.36.0 From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 08:46:58 2022 Received: (at 52835) by debbugs.gnu.org; 28 May 2022 12:46:58 +0000 Received: from localhost ([127.0.0.1]:36610 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqM-0000zp-8X for submit@debbugs.gnu.org; Sat, 28 May 2022 08:46:58 -0400 Received: from jpoiret.xyz ([206.189.101.64]:34508) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqJ-0000zN-57 for 52835@debbugs.gnu.org; Sat, 28 May 2022 08:46:55 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 1857F1851E0; Sat, 28 May 2022 12:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1653742014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ixw8yr8Ja0KkKYb69ww3cZkLxihNOJ0RTZ2N/FG2uPc=; b=WBcDmxULcaHC5ujD48R61hyXdAKa4aOx7hkIETb/2zyda/kJLsyKwm/6sqw+naNGimK8B6 ynZaunx7rvDdu7b2J2bhZqbVSlTEnJP6GWxGbMHeqXgQbvp8qgV3fm65Zd2XJW1OqzkmzS 7itClbIulKr51Pfs5MJIvhXyw3dn49hJqJVCmHEl58MymFDtTo8eWj+9ToXaEB8zoRySiQ Byy1bg7MbpXaBV4HOzHKw4OqzVTNGODCUw6falsEkwgEcFrmvgmPBnLLAPdNbxi2/kcmbv f+02W5lThQW5qwQjfL+cTFP6OeKFqhd41TMO5MnJ9XYTq/zdZm0UoaideNZX1g== From: Josselin Poiret To: Josselin Poiret , Timothy Sample Subject: [PATCH v4 2/4] Avoid double closes in piped-process. Date: Sat, 28 May 2022 14:46:32 +0200 Message-Id: <20220528124634.17353-3-dev@jpoiret.xyz> In-Reply-To: <20220528124634.17353-1-dev@jpoiret.xyz> References: <20220207165543.12723-1-dev@jpoiret.xyz> <20220528124634.17353-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (scm_piped_process): Avoid double closes. --- libguile/posix.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index e9f49fa27..155ad09b7 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1475,12 +1475,18 @@ scm_piped_process (SCM prog, SCM args, SCM from [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (scm_piped_process): Avoid double closes. --- libguile/posix.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index e9f49fa27..155ad09b7 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1475,12 +1475,18 @@ scm_piped_process (SCM prog, SCM args, SCM from [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * libguile/posix.c (scm_piped_process): Avoid double closes. --- libguile/posix.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index e9f49fa27..155ad09b7 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1475,12 +1475,18 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to) if (reading) { close (c2p[0]); - close (c2p[1]); + if (c2p[1] != c2p[0]) + close (c2p[1]); } if (writing) { - close (p2c[0]); - close (p2c[1]); + if (!(reading && (c2p[0] == p2c[0] || + c2p[1] == p2c[0]))) + close (p2c[0]); + if (p2c[0] != p2c[1] && + !(reading && (c2p[0] == p2c[1] || + c2p[1] == p2c[1]))) + close (p2c[1]); } errno = errno_save; SCM_SYSERROR; @@ -1488,7 +1494,7 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to) if (reading) close (c2p[1]); - if (writing) + if (writing && !(reading && c2p[1] == p2c[0])) close (p2c[0]); return scm_from_int (pid); -- 2.36.0 From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 08:46:58 2022 Received: (at 52835) by debbugs.gnu.org; 28 May 2022 12:46:58 +0000 Received: from localhost ([127.0.0.1]:36612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqM-0000zx-Ht for submit@debbugs.gnu.org; Sat, 28 May 2022 08:46:58 -0400 Received: from jpoiret.xyz ([206.189.101.64]:34594) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqK-0000za-9I for 52835@debbugs.gnu.org; Sat, 28 May 2022 08:46:56 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 2A2081852FC; Sat, 28 May 2022 12:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1653742015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PD0X5NCtWede9t396/8icAU7NcQpJXOWrnNGNcLqlOs=; b=vptl/SyzHRTDXqtlzafuPdMdmQBQ2Rls8+XaQutTBpRMalG+07LLtRSaBa23KR/uqNGAxg wxLbDibHouM90Ofc/mAJCtEsOvMu/jgRrKuA0rhoE2tQoGtRvAmHwnO0VHlklWsmdb5H0Y H/+0TrH5xCwKZZAc+6o9j47TgaNgdHFeHphzPvmoclDmUBEz25QtwkyTZrsX04kt4/HQ18 t/+G+ln631j4rNsBHvGAhPenKiZsJWJejV8WK04qEilmRUf45hk82ispJWPgYV9kgLaQMI GkOGcc1WFV5CS01l04nYuDPgKLyxlCjLNjFxf3Avk32aOtJLTykvYyUJ9z/BKQ== From: Josselin Poiret To: Josselin Poiret , Timothy Sample Subject: [PATCH v4 3/4] Remove useless closing code in start_child. Date: Sat, 28 May 2022 14:46:33 +0200 Message-Id: <20220528124634.17353-4-dev@jpoiret.xyz> In-Reply-To: <20220528124634.17353-1-dev@jpoiret.xyz> References: <20220207165543.12723-1-dev@jpoiret.xyz> <20220528124634.17353-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (start_child): We're closing all fds anyway, no need to try to close some specific ones beforehand. --- libguile/posix.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 155ad09b7..94a043cca 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1363, 12 +1363, 6 @@ start_child (const char *exec_file, char **exec_ [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (start_child): We're closing all fds anyway, no need to try to close some specific ones beforehand. --- libguile/posix.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 155ad09b7..94a043cca 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1363,12 +1363,6 @@ start_child (const char *exec_file, char **exec_ [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * libguile/posix.c (start_child): We're closing all fds anyway, no need to try to close some specific ones beforehand. --- libguile/posix.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 155ad09b7..94a043cca 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1363,12 +1363,6 @@ start_child (const char *exec_file, char **exec_argv, child. Return directly in either case. */ return pid; - /* The child. */ - if (reading) - close (c2p[0]); - if (writing) - close (p2c[1]); - /* Close all file descriptors in ports inherited from the parent except for in, out, and err. Heavy-handed, but robust. */ while (max_fd--) -- 2.36.0 From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 08:47:19 2022 Received: (at 52835) by debbugs.gnu.org; 28 May 2022 12:47:19 +0000 Received: from localhost ([127.0.0.1]:36619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqV-00010z-Qc for submit@debbugs.gnu.org; Sat, 28 May 2022 08:47:19 -0400 Received: from jpoiret.xyz ([206.189.101.64]:34330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqH-0000zJ-AO for 52835@debbugs.gnu.org; Sat, 28 May 2022 08:46:57 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id A27381851D2; Sat, 28 May 2022 12:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1653742009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9a2TKcgtH3gM8aPOWqJRXSou9Q7z2mi4S3ctlqFY7lY=; b=JDvFtXlEHuBqgUbJkwhzgHhiLxfWe166HHIVAN1+4jkf1hCQM0clUoqx7zPh8L1ODgYXJR THjBHHi+o1yUCJaX6JNFIqcLCs1QMqjrjvPFM46bgGQ1dtqFMaZh28fZuERCKAUaEWRmcE MueeNLfcYeuTVabVwWow4UA7369I1D7A9qQkWtTATT3Er77GSLOJF77xES7fAWlLNUWXVZ /HsezcKKLIZxUzECQZGY8x3kmC/pHCGCTx08CV7pVk63EBwLVHyPlspKUeIP9raaOXKGyE LDaMFlzangrfLoC516Tiy0XIC2Ejr0mIVtkK4TsXzlGu/HIlpw0AycZhMaiwOQ== From: Josselin Poiret To: Josselin Poiret , Timothy Sample Subject: [PATCH v4 0/4] Improve safety of start_child and piped-process. Date: Sat, 28 May 2022 14:46:30 +0200 Message-Id: <20220528124634.17353-1-dev@jpoiret.xyz> In-Reply-To: <20220207165543.12723-1-dev@jpoiret.xyz> References: <20220207165543.12723-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Level: **** X-Spamd-Bar: ++++ X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: retitle 52835 Improve safety of start_child and piped-process. thanks Hello everyone, This time, it's another Guix bug [1] that prompted me to have a closer look at piped-process and start_child, which don't seem to be very multi-thread safe. I've ended up with a couple of improvements [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: retitle 52835 Improve safety of start_child and piped-process. thanks Hello everyone, This time, it's another Guix bug [1] that prompted me to have a closer look at piped-process and start_child, which don't seem to be very multi-thread safe. I've ended up with a couple of improvements [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 T_SPF_HELO_TEMPERROR SPF: test of HELO record failed (temperror) -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager retitle 52835 Improve safety of start_child and piped-process. thanks Hello everyone, This time, it's another Guix bug [1] that prompted me to have a closer look at piped-process and start_child, which don't seem to be very multi-thread safe. I've ended up with a couple of improvements that IMO would make all procedures relying on them more robust. Here's roughly what I did: * Fix the fd closing code that was bogus for unusual values for in, out, err for start_child. * Check for double closes and avoid them, so that we don't accidentally close an fd that another thread could have opened. * Remove some closing code in the child, since we're already generically closing all fds. * Add a pipe from the child to the parent that the former uses to report its errno to the latter. This avoids the use of strerror and printf in the child after forking, since they are not async-signal safe. As a side effect, this lets piped-error raise the proper system exception for the child errno, instead of returning the PID of a process that hasn't exec'd successfully. [1] https://issues.guix.gnu.org/55441 Best, Josselin Poiret (4): Fix child spawning closing standard fds prematurely. Avoid double closes in piped-process. Remove useless closing code in start_child. Make start_child propagate the child errno to the parent. configure.ac | 3 +- libguile/posix.c | 187 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 138 insertions(+), 52 deletions(-) -- 2.36.0 From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 08:47:19 2022 Received: (at 52835) by debbugs.gnu.org; 28 May 2022 12:47:20 +0000 Received: from localhost ([127.0.0.1]:36621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqh-00011D-5j for submit@debbugs.gnu.org; Sat, 28 May 2022 08:47:19 -0400 Received: from jpoiret.xyz ([206.189.101.64]:34680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuvqN-000109-Ca for 52835@debbugs.gnu.org; Sat, 28 May 2022 08:47:00 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 72C36184F6B; Sat, 28 May 2022 12:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1653742016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ft8LuG4qiXeT1gYvoFLiOHBhudfMVvEZobNT06WyUR4=; b=voSIBD5nUiESr+ZaHCjvk9k08GAcS2XxA1NL4SW46DMm4/R8peeETsMSZZmaCi9SUgVzSr Q38vtEHxVUUr4eiPc3EB5H/0A+RcWK3LbUWzcCHgPGyLIK7jmFdczJpBkizanZ5JIrNezw 5ud7kPVNF7zRnOysoLgHwshBkGNmIEfZeF+LHQxyfvZJEde3aelvaOxhlVnuvQYBIZni8O tp6rrsxr/iDOp7EUolN3eRSuzcj3uU6LGQjDuJhFd/DiXUg5sg4kuZbMwa84IdZSsJmz95 zjbsgYTOMUJCZROK8R47SpbNqdCRzt82F9/lZmuBLqHi0ronCixua5nRDPj0qg== From: Josselin Poiret To: Josselin Poiret , Timothy Sample Subject: [PATCH v4 4/4] Make start_child propagate the child errno to the parent. Date: Sat, 28 May 2022 14:46:34 +0200 Message-Id: <20220528124634.17353-5-dev@jpoiret.xyz> In-Reply-To: <20220528124634.17353-1-dev@jpoiret.xyz> References: <20220207165543.12723-1-dev@jpoiret.xyz> <20220528124634.17353-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * configure.ac: Add AC_CHECK_FUNCS for pipe2. * libguile/posix.c (start_child): Use a pipe to transmit the child's errno to the parent, which can then use it to signal an error instead of writing to i [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * configure.ac: Add AC_CHECK_FUNCS for pipe2. * libguile/posix.c (start_child): Use a pipe to transmit the child's errno to the parent, which can then use it to signal an error instead of writing to i [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * configure.ac: Add AC_CHECK_FUNCS for pipe2. * libguile/posix.c (start_child): Use a pipe to transmit the child's errno to the parent, which can then use it to signal an error instead of writing to its error file descriptor. This also avoids the use of async-signal unsafe functions inside the child before exec. Use pipe2 when available. (dup_handle_error,dup2_handle_error): Ditto. --- configure.ac | 3 +- libguile/posix.c | 113 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 89 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index 827e1c09d..19441a52e 100644 --- a/configure.ac +++ b/configure.ac @@ -525,6 +525,7 @@ AC_CHECK_HEADERS([assert.h crt_externs.h]) # fork - unavailable on Windows # sched_getaffinity, sched_setaffinity - GNU extensions (glibc) # sendfile - non-POSIX, found in glibc +# pipe2 - non-POSIX, found on Linux # AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid \ fesetround ftime ftruncate fchown fchmod getcwd geteuid getsid \ @@ -536,7 +537,7 @@ AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid \ getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp \ index bcopy memcpy rindex truncate isblank _NSGetEnviron \ strcoll strcoll_l strtod_l strtol_l newlocale uselocale utimensat \ - sched_getaffinity sched_setaffinity sendfile]) + sched_getaffinity sched_setaffinity sendfile pipe2]) # The newlib C library uses _NL_ prefixed locale langinfo constants. AC_CHECK_DECLS([_NL_NUMERIC_GROUPING], [], [], [[#include ]]) diff --git a/libguile/posix.c b/libguile/posix.c index 94a043cca..79f097756 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1284,8 +1284,7 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, is specialized for that particular environment where it doesn't make sense to report errors via exceptions. It uses dup(2) to duplicate the file descriptor FD, does *not* close the original FD, and returns - the new descriptor. If dup(2) fails, print an error message to ERR - and abort. */ + the new descriptor. If dup(2) fails, send errno to ERR and abort. */ static int dup_handle_error (int fd, int err) { @@ -1299,9 +1298,12 @@ dup_handle_error (int fd, int err) { /* At this point we are in the child process before exec. We cannot safely raise an exception in this environment. */ - const char *msg = strerror (errno); - fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); - _exit (127); /* Use exit status 127, as with other exec errors. */ + int errno_save = errno; + while (write (err, &errno_save, sizeof (errno)) == -1) + if (errno != EINTR) + break; + + _exit (127); } return new_fd; @@ -1311,8 +1313,8 @@ dup_handle_error (int fd, int err) is specialized for that particular environment where it doesn't make sense to report errors via exceptions. It uses dup2(2) to duplicate the file descriptor FD, does *not* close the original FD, and returns - the new descriptor. If dup2(2) fails, print an error message to ERR - and abort. */ + the new descriptor. If dup2(2) fails, send errno to ERR and + abort. */ static int dup2_handle_error (int fd, int to, int err) { @@ -1326,9 +1328,11 @@ dup2_handle_error (int fd, int to, int err) { /* At this point we are in the child process before exec. We cannot safely raise an exception in this environment. */ - const char *msg = strerror (errno); - fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); - _exit (127); /* Use exit status 127, as with other exec errors. */ + int errno_save = errno; + while (write (err, &errno_save, sizeof (errno)) == -1) + if (errno != EINTR) + break; + _exit (127); } return new_fd; @@ -1347,6 +1351,8 @@ start_child (const char *exec_file, char **exec_argv, { int pid; int max_fd = 1024; + int errno_save; + int errpipefds[2]; #if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) { @@ -1356,17 +1362,73 @@ start_child (const char *exec_file, char **exec_argv, } #endif +/* Setup a pipe to receive the errno of the child, which can't call + async-signal unsafe functions such as strerror or the printf family. */ +#ifdef HAVE_PIPE2 + if (pipe2 (errpipefds, O_CLOEXEC)) + return -1; +#else + if (pipe (errpipefds)) + return -1; + /* Set the writer end as close-on-exec, so that it automatically + closes on successful exec, and so that other threads that fork+exec + will not block it. + + XXX: There can potentially be a race issue between the pipe and + fcntl calls, such that another thread that forks in between + inherits the fd without CLOEXEC. There is no POSIXy way to make + the combination atomic, so just hope that any other fork would + release resources it doesn't need, like we do. */ + if (fcntl (errpipefds[1], F_SETFD, fcntl (errpipefds[1], F_GETFD) | FD_CLOEXEC)) + { + errno_save = errno; + close (errpipefds[0]); + close (errpipefds[1]); + errno = errno_save; + return -1; + } +#endif + pid = fork (); if (pid != 0) - /* The parent, with either and error (pid == -1), or the PID of the - child. Return directly in either case. */ - return pid; + { + /* We're in the parent process. */ + int read_count; + close (errpipefds[1]); + if (pid == -1) + { + /* Fork failed. */ + errno_save = errno; + close (errpipefds[0]); + errno = errno_save; + return -1; + } + + /* Fork successful, try to read a potential child errno from the pipe. */ + while ((read_count = read(errpipefds[0], &errno_save, sizeof (errno))) == -1) + if (errno != EAGAIN && errno != EINTR) + break; + if (read_count == -1) + errno_save = errno; + close (errpipefds[0]); + if (read_count != 0) + { + /* Either the read failed (-1) or the child sent us an errno (> 0) */ + errno = errno_save; + return -1; + } + return pid; + } + + /* From now on, we are single threaded because of fork, so double + closes should be a no-op. */ /* Close all file descriptors in ports inherited from the parent - except for in, out, and err. Heavy-handed, but robust. */ + except for in, out, err and the error pipe back to the parent. + Heavy-handed, but robust. */ while (max_fd--) - if (max_fd != in && max_fd != out && max_fd != err) + if (max_fd != in && max_fd != out && max_fd != err && max_fd != errpipefds[1]) close (max_fd); /* Ignore errors on these open() calls. */ @@ -1382,16 +1444,16 @@ start_child (const char *exec_file, char **exec_argv, in/out/err. Note that dup2 doesn't do anything if its arguments are equal. */ if (out == 0) - out = dup_handle_error (out, err); + out = dup_handle_error (out, errpipefds[1]); if (err == 0) - err = dup_handle_error (err, err); - dup2_handle_error (in, 0, err); + err = dup_handle_error (err, errpipefds[1]); + dup2_handle_error (in, 0, errpipefds[1]); if (err == 1) - err = dup_handle_error (err, err); - dup2_handle_error (out, 1, err); + err = dup_handle_error (err, errpipefds[1]); + dup2_handle_error (out, 1, errpipefds[1]); - dup2_handle_error (err, 2, err); + dup2_handle_error (err, 2, errpipefds[1]); if (in > 2) close (in); if (out > 2) close (out); @@ -1400,11 +1462,10 @@ start_child (const char *exec_file, char **exec_argv, execvp (exec_file, exec_argv); /* The exec failed! There is nothing sensible to do. */ - { - const char *msg = strerror (errno); - dprintf (2, "In execvp of %s: %s\n", - exec_file, msg); - } + errno_save = errno; + while (write (errpipefds[1], &errno_save, sizeof (errno)) == -1) + if (errno != EINTR) + break; /* Use exit status 127, like shells in this case, as per POSIX . */ -- 2.36.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 05 02:48:28 2022 Received: (at 52835) by debbugs.gnu.org; 5 Sep 2022 06:48:28 +0000 Received: from localhost ([127.0.0.1]:46245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV5uF-0000bN-Ht for submit@debbugs.gnu.org; Mon, 05 Sep 2022 02:48:28 -0400 Received: from jpoiret.xyz ([206.189.101.64]:38352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV5uD-0000b7-0f for 52835@debbugs.gnu.org; Mon, 05 Sep 2022 02:48:26 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 29522184F64; Mon, 5 Sep 2022 06:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1662360503; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YKfcZXjN4cNvmU98yG2F66Db6ZGbKy6Ov9yS2/AbDKI=; b=LCLt0swBgyILncbcRbzfA4x1/enLekIg3TqUWGzrqvFQwbyHVLh2fLiZMjiDnHlcJXfaZ3 oCMVRagM/1Eu/AHTuDU0g5XwBc6JyR7LmObwgxsQth1a4Xvkd5zlAjyN+cTUqw+6lWN0wv xqA4aQkCh+AzXlLGr73u/m2DWa5/UqWfOwsCP1wriowq4Ri6TXjQsfXqGjK7H6DAgfKFqc NWVzaVCUsloNY5mnKN+UScbqjl1nn1zbsfiuxLQ6F2CLG2ywqjsiijL1afJ+BN1KVUgU6B 1y5o/rATCt/BtYYEit1dewzE8aB/VooFtYDYkA2XcpBmp1L2tE8/TeJvg6dynw== From: Josselin Poiret To: 52835@debbugs.gnu.org Subject: [PATCH v5 0/3] Move spawning procedures to posix_spawn. Date: Mon, 5 Sep 2022 08:48:12 +0200 Message-Id: In-Reply-To: <20220528124634.17353-1-dev@jpoiret.xyz> References: <20220528124634.17353-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Level: **** X-Spamd-Bar: ++++ X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi everyone, As was discussed on IRC, if we're going to rewrite a non-negligible part of posix.c, let's at least do it right and use posix_spawn to handle the process spawning side of things. This is quite complex [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: Timothy Sample , Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Hi everyone, As was discussed on IRC, if we're going to rewrite a non-negligible part of posix.c, let's at least do it right and use posix_spawn to handle the process spawning side of things. This is quite complex to get right in general (highlighted by this very bug) and so people have already done the hard work for us. Additionally, we use Gnulib's posix_spawn, so that it is available on all supported systems. I then adjusted all the procedures to use posix_spawn instead of scm_piped_process and removed the latter, and the tests in popen.test, posix.test. There are two inderminates here: * I don't have anything other than a Linux system to test. This would need some feedback for at least Mach and win32. * This changes the interfaces (for the better, in my opinion): whenever possible, posix_spawn reports child starting failures as a parent errno, meaning that for eg. non- existing binaries, system* now throws an exception instead of returning a pid that will have an exit status code of 127. This means that existing code that relies on that behavior will need to be changed, the first example being the test suite which I adapted to actually check for exceptions instead. Some tests were removed because they no longer make sense: in posix.test, https://bugs.gnu.org/13166, exit code for nonexistent file and https://bugs.gnu.org/55596 are superseded by "exception for nonexistent file". Also, I have no experience in using Gnulib so I'm not 100% sure I committed exactly the right files, I'd love it if someone could check this is ok. What do you all think about this approach? Josselin Poiret (3): Update gnulib to 0.1.5414-8204d and add posix_spawn, posix_spawnp. Add spawn*. Move popen and posix procedures to spawn*. GNUmakefile | 2 +- build-aux/announce-gen | 69 +- build-aux/gendocs.sh | 50 +- build-aux/git-version-gen | 13 +- build-aux/gitlog-to-changelog | 4 +- build-aux/gnu-web-doc-update | 4 +- build-aux/gnupload | 4 +- build-aux/useless-if-before-free | 6 +- build-aux/vc-list-files | 2 +- doc/gendocs_template | 4 +- doc/gendocs_template_min | 2 +- gnulib-local/m4/clock_time.m4.diff | 12 +- lib/Makefile.am | 1252 +++++++++------- lib/_Noreturn.h | 2 +- lib/accept.c | 2 +- lib/accept4.c | 4 +- lib/access.c | 31 + lib/alignof.h | 2 +- lib/alloca.c | 35 - lib/alloca.in.h | 2 +- lib/arg-nonnull.h | 2 +- lib/arpa_inet.in.h | 2 +- lib/asnprintf.c | 2 +- lib/assure.h | 2 +- lib/attribute.h | 10 +- lib/basename-lgpl.c | 2 +- lib/basename-lgpl.h | 2 +- lib/binary-io.c | 2 +- lib/binary-io.h | 4 +- lib/bind.c | 2 +- lib/btowc.c | 2 +- lib/byteswap.in.h | 2 +- lib/c++defs.h | 2 +- lib/c-ctype.c | 2 +- lib/c-ctype.h | 2 +- lib/c-strcase.h | 2 +- lib/c-strcasecmp.c | 2 +- lib/c-strcaseeq.h | 2 +- lib/c-strncasecmp.c | 2 +- lib/canonicalize-lgpl.c | 2 +- lib/cdefs.h | 76 +- lib/ceil.c | 4 +- lib/cloexec.c | 2 +- lib/cloexec.h | 2 +- lib/close.c | 2 +- lib/concat-filename.c | 73 + lib/concat-filename.h | 46 + lib/connect.c | 2 +- lib/copysign.c | 4 +- lib/dirent.in.h | 24 +- lib/dirfd.c | 2 +- lib/dirname-lgpl.c | 2 +- lib/dirname.h | 2 +- lib/dup2.c | 2 +- lib/duplocale.c | 4 +- lib/dynarray.h | 2 +- lib/eloop-threshold.h | 2 +- lib/errno.in.h | 2 +- lib/fcntl.c | 2 +- lib/fcntl.in.h | 6 +- lib/fd-hook.c | 2 +- lib/fd-hook.h | 2 +- lib/filename.h | 2 +- lib/findprog-in.c | 399 ++++++ lib/findprog.h | 77 + lib/flexmember.h | 2 +- lib/float+.h | 2 +- lib/float.c | 2 +- lib/float.in.h | 2 +- lib/flock.c | 2 +- lib/floor.c | 4 +- lib/free.c | 2 +- lib/frexp.c | 2 +- lib/fstat.c | 2 +- lib/fsync.c | 2 +- lib/full-read.c | 2 +- lib/full-read.h | 2 +- lib/full-write.c | 2 +- lib/full-write.h | 2 +- lib/gai_strerror.c | 2 +- lib/getaddrinfo.c | 2 +- lib/getdtablesize.c | 2 +- lib/getlogin.c | 2 +- lib/getpeername.c | 2 +- lib/getrandom.c | 2 +- lib/getsockname.c | 2 +- lib/getsockopt.c | 2 +- lib/gettext.h | 15 +- lib/hard-locale.c | 2 +- lib/hard-locale.h | 2 +- lib/iconv.c | 2 +- lib/iconv.in.h | 2 +- lib/iconv_close.c | 2 +- lib/iconv_open-aix.gperf | 2 +- lib/iconv_open-hpux.gperf | 2 +- lib/iconv_open-irix.gperf | 2 +- lib/iconv_open-osf.gperf | 2 +- lib/iconv_open-solaris.gperf | 2 +- lib/iconv_open-zos.gperf | 2 +- lib/iconv_open-zos.h | 329 +++++ lib/iconv_open.c | 2 +- lib/iconveh.h | 7 +- lib/idx.h | 22 +- lib/inet_ntop.c | 2 +- lib/inet_pton.c | 2 +- lib/intprops-internal.h | 392 +++++ lib/intprops.h | 359 +---- lib/inttypes.h | 1509 ++++++++++++++++++++ lib/inttypes.in.h | 2 +- lib/isfinite.c | 4 +- lib/isinf.c | 4 +- lib/isnan.c | 2 +- lib/isnand-nolibm.h | 2 +- lib/isnand.c | 2 +- lib/isnanf-nolibm.h | 2 +- lib/isnanf.c | 2 +- lib/isnanl-nolibm.h | 2 +- lib/isnanl.c | 2 +- lib/itold.c | 2 +- lib/langinfo.in.h | 2 +- lib/lc-charset-dispatch.c | 2 +- lib/lc-charset-dispatch.h | 2 +- lib/libc-config.h | 13 +- lib/libunistring.valgrind | 4 +- lib/limits.in.h | 2 +- lib/link.c | 2 +- lib/listen.c | 2 +- lib/localcharset.c | 2 +- lib/localcharset.h | 2 +- lib/locale.in.h | 2 +- lib/localeconv.c | 2 +- lib/log.c | 4 +- lib/log1p.c | 4 +- lib/lstat.c | 2 +- lib/malloc.c | 2 +- lib/malloc/.dirstamp | 0 lib/malloc/dynarray-skeleton.c | 2 +- lib/malloc/dynarray-skeleton.gl.h | 529 +++++++ lib/malloc/dynarray.gl.h | 174 +++ lib/malloc/dynarray.h | 2 +- lib/malloc/dynarray_at_failure.c | 2 +- lib/malloc/dynarray_emplace_enlarge.c | 2 +- lib/malloc/dynarray_finalize.c | 2 +- lib/malloc/dynarray_resize.c | 2 +- lib/malloc/dynarray_resize_clear.c | 2 +- lib/malloc/scratch_buffer.h | 2 +- lib/malloc/scratch_buffer_dupfree.c | 2 +- lib/malloc/scratch_buffer_grow.c | 2 +- lib/malloc/scratch_buffer_grow_preserve.c | 2 +- lib/malloc/scratch_buffer_set_array_size.c | 2 +- lib/malloca.c | 12 +- lib/malloca.h | 2 +- lib/math.c | 2 +- lib/math.in.h | 16 +- lib/mbrtowc-impl-utf8.h | 2 +- lib/mbrtowc-impl.h | 2 +- lib/mbrtowc.c | 2 +- lib/mbsinit.c | 2 +- lib/mbtowc-impl.h | 2 +- lib/mbtowc-lock.c | 2 +- lib/mbtowc-lock.h | 2 +- lib/mbtowc.c | 2 +- lib/memchr.c | 2 +- lib/memchr.valgrind | 2 +- lib/mempcpy.c | 2 +- lib/minmax.h | 2 +- lib/mkdir.c | 4 +- lib/mkostemp.c | 2 +- lib/mktime-internal.h | 2 +- lib/mktime.c | 30 +- lib/msvc-inval.c | 2 +- lib/msvc-inval.h | 2 +- lib/msvc-nothrow.c | 2 +- lib/msvc-nothrow.h | 2 +- lib/netdb.in.h | 2 +- lib/netinet_in.in.h | 2 +- lib/nl_langinfo-lock.c | 2 +- lib/nl_langinfo.c | 2 +- lib/nproc.c | 24 +- lib/nproc.h | 2 +- lib/nstrftime.c | 28 +- lib/open.c | 2 +- lib/pathmax.h | 2 +- lib/pipe.c | 2 +- lib/pipe2.c | 2 +- lib/poll.c | 2 +- lib/poll.in.h | 2 +- lib/printf-args.c | 2 +- lib/printf-args.h | 2 +- lib/printf-parse.c | 2 +- lib/printf-parse.h | 2 +- lib/putenv.c | 4 +- lib/raise.c | 2 +- lib/rawmemchr.c | 78 +- lib/rawmemchr.valgrind | 2 +- lib/read.c | 2 +- lib/readlink.c | 6 +- lib/realloc.c | 2 +- lib/recv.c | 2 +- lib/recvfrom.c | 2 +- lib/regcomp.c | 831 +++++------ lib/regex.c | 3 +- lib/regex.h | 52 +- lib/regex_internal.c | 64 +- lib/regex_internal.h | 51 +- lib/regexec.c | 95 +- lib/rename.c | 4 +- lib/rmdir.c | 2 +- lib/round.c | 4 +- lib/safe-read.c | 2 +- lib/safe-read.h | 2 +- lib/safe-write.c | 2 +- lib/safe-write.h | 2 +- lib/same-inode.h | 2 +- lib/sched.h | 580 ++++++++ lib/sched.in.h | 99 ++ lib/scratch_buffer.h | 2 +- lib/select.c | 2 +- lib/send.c | 2 +- lib/sendto.c | 2 +- lib/setenv.c | 2 +- lib/setlocale-lock.c | 2 +- lib/setlocale_null.c | 2 +- lib/setlocale_null.h | 2 +- lib/setsockopt.c | 2 +- lib/shutdown.c | 2 +- lib/signal.in.h | 2 +- lib/signbitd.c | 2 +- lib/signbitf.c | 2 +- lib/signbitl.c | 2 +- lib/size_max.h | 2 +- lib/snprintf.c | 2 +- lib/socket.c | 2 +- lib/sockets.c | 4 +- lib/sockets.h | 2 +- lib/spawn.c | 34 + lib/spawn.h | 1499 +++++++++++++++++++ lib/spawn.in.h | 992 +++++++++++++ lib/spawn_int.h | 72 + lib/spawni.c | 965 +++++++++++++ lib/spawnp.c | 34 + lib/stat-time.c | 2 +- lib/stat-time.h | 8 +- lib/stat-w32.c | 2 +- lib/stat-w32.h | 2 +- lib/stat.c | 2 +- lib/stdalign.in.h | 2 +- lib/stdbool.h | 116 ++ lib/stdbool.in.h | 27 +- lib/stdckdint.h | 38 + lib/stdckdint.in.h | 37 + lib/stddef.in.h | 2 +- lib/stdint.in.h | 2 +- lib/stdio-read.c | 168 +++ lib/stdio-write.c | 206 +++ lib/stdio.in.h | 86 +- lib/stdlib.in.h | 66 +- lib/stpcpy.c | 49 + lib/strchrnul.c | 142 ++ lib/strchrnul.valgrind | 28 + lib/strdup.c | 2 +- lib/streq.h | 2 +- lib/strftime.h | 4 +- lib/striconveh.c | 106 +- lib/striconveh.h | 2 +- lib/string.in.h | 175 ++- lib/stripslash.c | 2 +- lib/sys-limits.h | 2 +- lib/sys_file.in.h | 2 +- lib/sys_random.in.h | 8 +- lib/sys_select.in.h | 15 +- lib/sys_socket.c | 2 +- lib/sys_socket.in.h | 2 +- lib/sys_stat.in.h | 30 +- lib/sys_time.in.h | 2 +- lib/sys_times.in.h | 2 +- lib/sys_types.in.h | 2 +- lib/sys_uio.in.h | 2 +- lib/tempname.c | 176 +-- lib/tempname.h | 4 +- lib/time-internal.h | 4 +- lib/time.in.h | 13 +- lib/time_r.c | 2 +- lib/time_rz.c | 4 +- lib/timegm.c | 2 +- lib/times.c | 2 +- lib/trunc.c | 4 +- lib/tzset.c | 4 +- lib/unistd.c | 2 +- lib/unistd.in.h | 21 +- lib/unsetenv.c | 2 +- lib/vasnprintf.c | 241 +--- lib/vasnprintf.h | 2 +- lib/verify.h | 14 +- lib/vsnprintf.c | 2 +- lib/w32sock.h | 2 +- lib/warn-on-use.h | 8 +- lib/wchar.in.h | 73 +- lib/wcrtomb.c | 2 +- lib/wctype-h.c | 2 +- lib/wctype.in.h | 2 +- lib/windows-initguard.h | 2 +- lib/windows-spawn.c | 727 ++++++++++ lib/windows-spawn.h | 157 ++ lib/write.c | 2 +- lib/xalloc-oversized.h | 2 +- lib/xsize.c | 2 +- lib/xsize.h | 2 +- libguile/posix.c | 221 +-- m4/00gnulib.m4 | 2 +- m4/__inline.m4 | 2 +- m4/absolute-header.m4 | 2 +- m4/accept4.m4 | 2 +- m4/access.m4 | 16 + m4/alloca.m4 | 12 +- m4/arpa_inet_h.m4 | 2 +- m4/autobuild.m4 | 2 +- m4/btowc.m4 | 2 +- m4/builtin-expect.m4 | 2 +- m4/byteswap.m4 | 10 +- m4/canonicalize.m4 | 2 +- m4/ceil.m4 | 2 +- m4/check-math-lib.m4 | 2 +- m4/clock_time.m4 | 20 +- m4/close.m4 | 2 +- m4/codeset.m4 | 2 +- m4/copysign.m4 | 2 +- m4/dirent_h.m4 | 2 +- m4/dirfd.m4 | 2 +- m4/double-slash-root.m4 | 2 +- m4/dup2.m4 | 2 +- m4/duplocale.m4 | 2 +- m4/eaccess.m4 | 12 + m4/eealloc.m4 | 2 +- m4/environ.m4 | 2 +- m4/errno_h.m4 | 12 +- m4/exponentd.m4 | 2 +- m4/exponentf.m4 | 2 +- m4/exponentl.m4 | 2 +- m4/extensions.m4 | 2 +- m4/extern-inline.m4 | 28 +- m4/fcntl-o.m4 | 2 +- m4/fcntl.m4 | 2 +- m4/fcntl_h.m4 | 2 +- m4/findprog-in.m4 | 11 + m4/flexmember.m4 | 2 +- m4/float_h.m4 | 22 +- m4/flock.m4 | 2 +- m4/floor.m4 | 2 +- m4/fpieee.m4 | 2 +- m4/free.m4 | 2 +- m4/frexp.m4 | 2 +- m4/fstat.m4 | 2 +- m4/fsync.m4 | 2 +- m4/func.m4 | 2 +- m4/getaddrinfo.m4 | 2 +- m4/getdtablesize.m4 | 2 +- m4/getlogin.m4 | 2 +- m4/getrandom.m4 | 2 +- m4/gettext.m4 | 383 +++++ m4/glibc2.m4 | 30 + m4/glibc21.m4 | 30 + m4/gnulib-cache.m4 | 8 +- m4/gnulib-common.m4 | 277 +++- m4/gnulib-comp.m4 | 743 ++++++---- m4/gnulib-tool.m4 | 10 +- m4/host-cpu-c-abi.m4 | 7 +- m4/hostent.m4 | 2 +- m4/iconv.m4 | 26 +- m4/iconv_h.m4 | 18 +- m4/iconv_open-utf.m4 | 2 +- m4/iconv_open.m4 | 2 +- m4/include_next.m4 | 8 +- m4/inet_ntop.m4 | 2 +- m4/inet_pton.m4 | 2 +- m4/intdiv0.m4 | 84 ++ m4/intl.m4 | 294 ++++ m4/intldir.m4 | 19 + m4/intlmacosx.m4 | 51 + m4/intmax.m4 | 33 + m4/intmax_t.m4 | 2 +- m4/inttypes-pri.m4 | 36 + m4/inttypes.m4 | 6 +- m4/inttypes_h.m4 | 2 +- m4/isfinite.m4 | 2 +- m4/isinf.m4 | 2 +- m4/isnan.m4 | 2 +- m4/isnand.m4 | 2 +- m4/isnanf.m4 | 2 +- m4/isnanl.m4 | 2 +- m4/langinfo_h.m4 | 2 +- m4/largefile.m4 | 9 +- m4/lcmessage.m4 | 31 + m4/ld-version-script.m4 | 2 +- m4/ldexp.m4 | 2 +- m4/lib-ld.m4 | 2 +- m4/lib-link.m4 | 8 +- m4/lib-prefix.m4 | 6 +- m4/libunistring.m4 | 2 +- m4/limits-h.m4 | 11 +- m4/link.m4 | 2 +- m4/localcharset.m4 | 2 +- m4/locale-fr.m4 | 2 +- m4/locale-ja.m4 | 2 +- m4/locale-zh.m4 | 2 +- m4/locale_h.m4 | 2 +- m4/localeconv.m4 | 2 +- m4/lock.m4 | 37 + m4/log.m4 | 2 +- m4/log1p.m4 | 2 +- m4/longlong.m4 | 106 ++ m4/lstat.m4 | 2 +- m4/malloc.m4 | 13 +- m4/malloca.m4 | 2 +- m4/math_h.m4 | 2 +- m4/mathfunc.m4 | 2 +- m4/mbrtowc.m4 | 2 +- m4/mbsinit.m4 | 2 +- m4/mbstate_t.m4 | 2 +- m4/mbtowc.m4 | 2 +- m4/memchr.m4 | 2 +- m4/mempcpy.m4 | 2 +- m4/minmax.m4 | 2 +- m4/mkdir.m4 | 2 +- m4/mkostemp.m4 | 2 +- m4/mktime.m4 | 31 +- m4/mmap-anon.m4 | 2 +- m4/mode_t.m4 | 2 +- m4/msvc-inval.m4 | 2 +- m4/msvc-nothrow.m4 | 2 +- m4/multiarch.m4 | 2 +- m4/netdb_h.m4 | 2 +- m4/netinet_in_h.m4 | 10 +- m4/nl_langinfo.m4 | 2 +- m4/nls.m4 | 32 + m4/nocrash.m4 | 2 +- m4/nproc.m4 | 2 +- m4/nstrftime.m4 | 2 +- m4/off_t.m4 | 2 +- m4/open-cloexec.m4 | 2 +- m4/open-slash.m4 | 2 +- m4/open.m4 | 2 +- m4/pathmax.m4 | 2 +- m4/pid_t.m4 | 2 +- m4/pipe.m4 | 2 +- m4/pipe2.m4 | 2 +- m4/po.m4 | 449 ++++++ m4/poll.m4 | 2 +- m4/poll_h.m4 | 2 +- m4/posix_spawn.m4 | 691 +++++++++ m4/printf-posix.m4 | 45 + m4/printf.m4 | 2 +- m4/progtest.m4 | 92 ++ m4/putenv.m4 | 2 +- m4/raise.m4 | 2 +- m4/rawmemchr.m4 | 2 +- m4/read.m4 | 2 +- m4/readlink.m4 | 2 +- m4/realloc.m4 | 12 +- m4/regex.m4 | 2 +- m4/rename.m4 | 2 +- m4/rmdir.m4 | 2 +- m4/round.m4 | 2 +- m4/safe-read.m4 | 2 +- m4/safe-write.m4 | 2 +- m4/sched_h.m4 | 106 ++ m4/select.m4 | 2 +- m4/servent.m4 | 2 +- m4/setenv.m4 | 2 +- m4/setlocale_null.m4 | 2 +- m4/sh-filename.m4 | 24 + m4/signal_h.m4 | 2 +- m4/signbit.m4 | 2 +- m4/size_max.m4 | 2 +- m4/snprintf.m4 | 2 +- m4/socketlib.m4 | 2 +- m4/sockets.m4 | 2 +- m4/socklen.m4 | 2 +- m4/sockpfaf.m4 | 2 +- m4/spawn_h.m4 | 151 ++ m4/ssize_t.m4 | 2 +- m4/stat-time.m4 | 2 +- m4/stat.m4 | 2 +- m4/std-gnu11.m4 | 2 +- m4/stdalign.m4 | 9 +- m4/stdbool.m4 | 124 +- m4/stddef_h.m4 | 16 +- m4/stdint.m4 | 10 +- m4/stdint_h.m4 | 2 +- m4/stdio_h.m4 | 33 +- m4/stdlib_h.m4 | 16 +- m4/stpcpy.m4 | 25 + m4/strchrnul.m4 | 50 + m4/strdup.m4 | 2 +- m4/string_h.m4 | 6 +- m4/sys_file_h.m4 | 2 +- m4/sys_random_h.m4 | 2 +- m4/sys_select_h.m4 | 2 +- m4/sys_socket_h.m4 | 9 +- m4/sys_stat_h.m4 | 8 +- m4/sys_time_h.m4 | 2 +- m4/sys_times_h.m4 | 2 +- m4/sys_types_h.m4 | 2 +- m4/sys_uio_h.m4 | 2 +- m4/tempname.m4 | 2 +- m4/threadlib.m4 | 64 +- m4/time_h.m4 | 6 +- m4/time_r.m4 | 2 +- m4/time_rz.m4 | 2 +- m4/timegm.m4 | 2 +- m4/times.m4 | 2 +- m4/tm_gmtoff.m4 | 2 +- m4/trunc.m4 | 2 +- m4/tzset.m4 | 2 +- m4/uintmax_t.m4 | 30 + m4/unistd_h.m4 | 191 +-- m4/vararrays.m4 | 72 + m4/vasnprintf.m4 | 2 +- m4/visibility.m4 | 2 +- m4/vsnprintf.m4 | 2 +- m4/warn-on-use.m4 | 2 +- m4/warnings.m4 | 2 +- m4/wchar_h.m4 | 6 +- m4/wchar_t.m4 | 2 +- m4/wcrtomb.m4 | 2 +- m4/wctype_h.m4 | 2 +- m4/wint_t.m4 | 2 +- m4/write.m4 | 2 +- m4/xsize.m4 | 2 +- m4/year2038.m4 | 12 +- m4/zzgnulib.m4 | 2 +- maint.mk | 68 +- module/ice-9/popen.scm | 83 +- test-suite/tests/popen.test | 14 +- test-suite/tests/posix.test | 36 +- 535 files changed, 16353 insertions(+), 3490 deletions(-) create mode 100644 lib/access.c create mode 100644 lib/concat-filename.c create mode 100644 lib/concat-filename.h create mode 100644 lib/findprog-in.c create mode 100644 lib/findprog.h create mode 100644 lib/iconv_open-zos.h create mode 100644 lib/intprops-internal.h create mode 100644 lib/inttypes.h create mode 100644 lib/malloc/.dirstamp create mode 100644 lib/malloc/dynarray-skeleton.gl.h create mode 100644 lib/malloc/dynarray.gl.h create mode 100644 lib/sched.h create mode 100644 lib/sched.in.h create mode 100644 lib/spawn.c create mode 100644 lib/spawn.h create mode 100644 lib/spawn.in.h create mode 100644 lib/spawn_int.h create mode 100644 lib/spawni.c create mode 100644 lib/spawnp.c create mode 100644 lib/stdbool.h create mode 100644 lib/stdckdint.h create mode 100644 lib/stdckdint.in.h create mode 100644 lib/stdio-read.c create mode 100644 lib/stdio-write.c create mode 100644 lib/stpcpy.c create mode 100644 lib/strchrnul.c create mode 100644 lib/strchrnul.valgrind create mode 100644 lib/windows-spawn.c create mode 100644 lib/windows-spawn.h create mode 100644 m4/access.m4 create mode 100644 m4/eaccess.m4 create mode 100644 m4/findprog-in.m4 create mode 100644 m4/gettext.m4 create mode 100644 m4/glibc2.m4 create mode 100644 m4/glibc21.m4 create mode 100644 m4/intdiv0.m4 create mode 100644 m4/intl.m4 create mode 100644 m4/intldir.m4 create mode 100644 m4/intlmacosx.m4 create mode 100644 m4/intmax.m4 create mode 100644 m4/inttypes-pri.m4 create mode 100644 m4/lcmessage.m4 create mode 100644 m4/lock.m4 create mode 100644 m4/longlong.m4 create mode 100644 m4/nls.m4 create mode 100644 m4/po.m4 create mode 100644 m4/posix_spawn.m4 create mode 100644 m4/printf-posix.m4 create mode 100644 m4/progtest.m4 create mode 100644 m4/sched_h.m4 create mode 100644 m4/sh-filename.m4 create mode 100644 m4/spawn_h.m4 create mode 100644 m4/stpcpy.m4 create mode 100644 m4/strchrnul.m4 create mode 100644 m4/uintmax_t.m4 create mode 100644 m4/vararrays.m4 base-commit: 61d8dab8eafd498306ce618582aab37497df77b4 -- 2.37.2 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 05 02:48:29 2022 Received: (at 52835) by debbugs.gnu.org; 5 Sep 2022 06:48:29 +0000 Received: from localhost ([127.0.0.1]:46249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV5uG-0000bZ-Tp for submit@debbugs.gnu.org; Mon, 05 Sep 2022 02:48:29 -0400 Received: from jpoiret.xyz ([206.189.101.64]:38436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV5uE-0000bA-Fb for 52835@debbugs.gnu.org; Mon, 05 Sep 2022 02:48:27 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id A87A9185300; Mon, 5 Sep 2022 06:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1662360505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jvCqw8ai/P+7edQ9+AjCAf90eqjPEWc72rGLIF1lkl4=; b=GU/yBT4MtF9F7Nf9Rv9m8sgwe5DH2CPSRKMPgTBcskfgdOjF/ujM+8Nis3/uQUzvXP8YD8 IBlKllmoc23AAruT3vIIbRR2J5sqENPiQnwDwU/45Pj+/ctPA2o50R0tRz7AsqJI6N7cBC v1FOBoTGGIS6c1s9jFl7atNJyUvRYi5LIvoxn7dBQUrzIlCR/tudgqphY1+2SpxSjb/uOR EeG8petBMi+r67q/HKzBtwIUQVLkk6ugn9KDy/hPGmr07jzzGhFsW5PIp1abW/YP0HrGdT tIULK2NDsyaX6UKNITVtcVCPhKiE29QP8iMedRgd2OkE8F1v5eN7XNpiucQitA== From: Josselin Poiret To: 52835@debbugs.gnu.org Subject: [PATCH v5 1/3] Update gnulib to 0.1.5414-8204d and add posix_spawn, posix_spawnp. Date: Mon, 5 Sep 2022 08:48:13 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Debbugs-Envelope-To: 52835 Cc: Timothy Sample , Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" --- GNUmakefile | 2 +- build-aux/announce-gen | 69 +- build-aux/gendocs.sh | 50 +- build-aux/git-version-gen | 13 +- build-aux/gitlog-to-changelog | 4 +- build-aux/gnu-web-doc-update | 4 +- build-aux/gnupload | 4 +- build-aux/useless-if-before-free | 6 +- build-aux/vc-list-files | 2 +- doc/gendocs_template | 4 +- doc/gendocs_template_min | 2 +- gnulib-local/m4/clock_time.m4.diff | 12 +- lib/Makefile.am | 1252 +++++++++------- lib/_Noreturn.h | 2 +- lib/accept.c | 2 +- lib/accept4.c | 4 +- lib/access.c | 31 + lib/alignof.h | 2 +- lib/alloca.c | 35 - lib/alloca.in.h | 2 +- lib/arg-nonnull.h | 2 +- lib/arpa_inet.in.h | 2 +- lib/asnprintf.c | 2 +- lib/assure.h | 2 +- lib/attribute.h | 10 +- lib/basename-lgpl.c | 2 +- lib/basename-lgpl.h | 2 +- lib/binary-io.c | 2 +- lib/binary-io.h | 4 +- lib/bind.c | 2 +- lib/btowc.c | 2 +- lib/byteswap.in.h | 2 +- lib/c++defs.h | 2 +- lib/c-ctype.c | 2 +- lib/c-ctype.h | 2 +- lib/c-strcase.h | 2 +- lib/c-strcasecmp.c | 2 +- lib/c-strcaseeq.h | 2 +- lib/c-strncasecmp.c | 2 +- lib/canonicalize-lgpl.c | 2 +- lib/cdefs.h | 76 +- lib/ceil.c | 4 +- lib/cloexec.c | 2 +- lib/cloexec.h | 2 +- lib/close.c | 2 +- lib/concat-filename.c | 73 + lib/concat-filename.h | 46 + lib/connect.c | 2 +- lib/copysign.c | 4 +- lib/dirent.in.h | 24 +- lib/dirfd.c | 2 +- lib/dirname-lgpl.c | 2 +- lib/dirname.h | 2 +- lib/dup2.c | 2 +- lib/duplocale.c | 4 +- lib/dynarray.h | 2 +- lib/eloop-threshold.h | 2 +- lib/errno.in.h | 2 +- lib/fcntl.c | 2 +- lib/fcntl.in.h | 6 +- lib/fd-hook.c | 2 +- lib/fd-hook.h | 2 +- lib/filename.h | 2 +- lib/findprog-in.c | 399 ++++++ lib/findprog.h | 77 + lib/flexmember.h | 2 +- lib/float+.h | 2 +- lib/float.c | 2 +- lib/float.in.h | 2 +- lib/flock.c | 2 +- lib/floor.c | 4 +- lib/free.c | 2 +- lib/frexp.c | 2 +- lib/fstat.c | 2 +- lib/fsync.c | 2 +- lib/full-read.c | 2 +- lib/full-read.h | 2 +- lib/full-write.c | 2 +- lib/full-write.h | 2 +- lib/gai_strerror.c | 2 +- lib/getaddrinfo.c | 2 +- lib/getdtablesize.c | 2 +- lib/getlogin.c | 2 +- lib/getpeername.c | 2 +- lib/getrandom.c | 2 +- lib/getsockname.c | 2 +- lib/getsockopt.c | 2 +- lib/gettext.h | 15 +- lib/hard-locale.c | 2 +- lib/hard-locale.h | 2 +- lib/iconv.c | 2 +- lib/iconv.in.h | 2 +- lib/iconv_close.c | 2 +- lib/iconv_open-aix.gperf | 2 +- lib/iconv_open-hpux.gperf | 2 +- lib/iconv_open-irix.gperf | 2 +- lib/iconv_open-osf.gperf | 2 +- lib/iconv_open-solaris.gperf | 2 +- lib/iconv_open-zos.gperf | 2 +- lib/iconv_open-zos.h | 329 +++++ lib/iconv_open.c | 2 +- lib/iconveh.h | 7 +- lib/idx.h | 22 +- lib/inet_ntop.c | 2 +- lib/inet_pton.c | 2 +- lib/intprops-internal.h | 392 +++++ lib/intprops.h | 359 +---- lib/inttypes.h | 1509 ++++++++++++++++++++ lib/inttypes.in.h | 2 +- lib/isfinite.c | 4 +- lib/isinf.c | 4 +- lib/isnan.c | 2 +- lib/isnand-nolibm.h | 2 +- lib/isnand.c | 2 +- lib/isnanf-nolibm.h | 2 +- lib/isnanf.c | 2 +- lib/isnanl-nolibm.h | 2 +- lib/isnanl.c | 2 +- lib/itold.c | 2 +- lib/langinfo.in.h | 2 +- lib/lc-charset-dispatch.c | 2 +- lib/lc-charset-dispatch.h | 2 +- lib/libc-config.h | 13 +- lib/libunistring.valgrind | 4 +- lib/limits.in.h | 2 +- lib/link.c | 2 +- lib/listen.c | 2 +- lib/localcharset.c | 2 +- lib/localcharset.h | 2 +- lib/locale.in.h | 2 +- lib/localeconv.c | 2 +- lib/log.c | 4 +- lib/log1p.c | 4 +- lib/lstat.c | 2 +- lib/malloc.c | 2 +- lib/malloc/.dirstamp | 0 lib/malloc/dynarray-skeleton.c | 2 +- lib/malloc/dynarray-skeleton.gl.h | 529 +++++++ lib/malloc/dynarray.gl.h | 174 +++ lib/malloc/dynarray.h | 2 +- lib/malloc/dynarray_at_failure.c | 2 +- lib/malloc/dynarray_emplace_enlarge.c | 2 +- lib/malloc/dynarray_finalize.c | 2 +- lib/malloc/dynarray_resize.c | 2 +- lib/malloc/dynarray_resize_clear.c | 2 +- lib/malloc/scratch_buffer.h | 2 +- lib/malloc/scratch_buffer_dupfree.c | 2 +- lib/malloc/scratch_buffer_grow.c | 2 +- lib/malloc/scratch_buffer_grow_preserve.c | 2 +- lib/malloc/scratch_buffer_set_array_size.c | 2 +- lib/malloca.c | 12 +- lib/malloca.h | 2 +- lib/math.c | 2 +- lib/math.in.h | 16 +- lib/mbrtowc-impl-utf8.h | 2 +- lib/mbrtowc-impl.h | 2 +- lib/mbrtowc.c | 2 +- lib/mbsinit.c | 2 +- lib/mbtowc-impl.h | 2 +- lib/mbtowc-lock.c | 2 +- lib/mbtowc-lock.h | 2 +- lib/mbtowc.c | 2 +- lib/memchr.c | 2 +- lib/memchr.valgrind | 2 +- lib/mempcpy.c | 2 +- lib/minmax.h | 2 +- lib/mkdir.c | 4 +- lib/mkostemp.c | 2 +- lib/mktime-internal.h | 2 +- lib/mktime.c | 30 +- lib/msvc-inval.c | 2 +- lib/msvc-inval.h | 2 +- lib/msvc-nothrow.c | 2 +- lib/msvc-nothrow.h | 2 +- lib/netdb.in.h | 2 +- lib/netinet_in.in.h | 2 +- lib/nl_langinfo-lock.c | 2 +- lib/nl_langinfo.c | 2 +- lib/nproc.c | 24 +- lib/nproc.h | 2 +- lib/nstrftime.c | 28 +- lib/open.c | 2 +- lib/pathmax.h | 2 +- lib/pipe.c | 2 +- lib/pipe2.c | 2 +- lib/poll.c | 2 +- lib/poll.in.h | 2 +- lib/printf-args.c | 2 +- lib/printf-args.h | 2 +- lib/printf-parse.c | 2 +- lib/printf-parse.h | 2 +- lib/putenv.c | 4 +- lib/raise.c | 2 +- lib/rawmemchr.c | 78 +- lib/rawmemchr.valgrind | 2 +- lib/read.c | 2 +- lib/readlink.c | 6 +- lib/realloc.c | 2 +- lib/recv.c | 2 +- lib/recvfrom.c | 2 +- lib/regcomp.c | 831 +++++------ lib/regex.c | 3 +- lib/regex.h | 52 +- lib/regex_internal.c | 64 +- lib/regex_internal.h | 51 +- lib/regexec.c | 95 +- lib/rename.c | 4 +- lib/rmdir.c | 2 +- lib/round.c | 4 +- lib/safe-read.c | 2 +- lib/safe-read.h | 2 +- lib/safe-write.c | 2 +- lib/safe-write.h | 2 +- lib/same-inode.h | 2 +- lib/sched.h | 580 ++++++++ lib/sched.in.h | 99 ++ lib/scratch_buffer.h | 2 +- lib/select.c | 2 +- lib/send.c | 2 +- lib/sendto.c | 2 +- lib/setenv.c | 2 +- lib/setlocale-lock.c | 2 +- lib/setlocale_null.c | 2 +- lib/setlocale_null.h | 2 +- lib/setsockopt.c | 2 +- lib/shutdown.c | 2 +- lib/signal.in.h | 2 +- lib/signbitd.c | 2 +- lib/signbitf.c | 2 +- lib/signbitl.c | 2 +- lib/size_max.h | 2 +- lib/snprintf.c | 2 +- lib/socket.c | 2 +- lib/sockets.c | 4 +- lib/sockets.h | 2 +- lib/spawn.c | 34 + lib/spawn.h | 1499 +++++++++++++++++++ lib/spawn.in.h | 992 +++++++++++++ lib/spawn_int.h | 72 + lib/spawni.c | 965 +++++++++++++ lib/spawnp.c | 34 + lib/stat-time.c | 2 +- lib/stat-time.h | 8 +- lib/stat-w32.c | 2 +- lib/stat-w32.h | 2 +- lib/stat.c | 2 +- lib/stdalign.in.h | 2 +- lib/stdbool.h | 116 ++ lib/stdbool.in.h | 27 +- lib/stdckdint.h | 38 + lib/stdckdint.in.h | 37 + lib/stddef.in.h | 2 +- lib/stdint.in.h | 2 +- lib/stdio-read.c | 168 +++ lib/stdio-write.c | 206 +++ lib/stdio.in.h | 86 +- lib/stdlib.in.h | 66 +- lib/stpcpy.c | 49 + lib/strchrnul.c | 142 ++ lib/strchrnul.valgrind | 28 + lib/strdup.c | 2 +- lib/streq.h | 2 +- lib/strftime.h | 4 +- lib/striconveh.c | 106 +- lib/striconveh.h | 2 +- lib/string.in.h | 175 ++- lib/stripslash.c | 2 +- lib/sys-limits.h | 2 +- lib/sys_file.in.h | 2 +- lib/sys_random.in.h | 8 +- lib/sys_select.in.h | 15 +- lib/sys_socket.c | 2 +- lib/sys_socket.in.h | 2 +- lib/sys_stat.in.h | 30 +- lib/sys_time.in.h | 2 +- lib/sys_times.in.h | 2 +- lib/sys_types.in.h | 2 +- lib/sys_uio.in.h | 2 +- lib/tempname.c | 176 +-- lib/tempname.h | 4 +- lib/time-internal.h | 4 +- lib/time.in.h | 13 +- lib/time_r.c | 2 +- lib/time_rz.c | 4 +- lib/timegm.c | 2 +- lib/times.c | 2 +- lib/trunc.c | 4 +- lib/tzset.c | 4 +- lib/unistd.c | 2 +- lib/unistd.in.h | 21 +- lib/unsetenv.c | 2 +- lib/vasnprintf.c | 241 +--- lib/vasnprintf.h | 2 +- lib/verify.h | 14 +- lib/vsnprintf.c | 2 +- lib/w32sock.h | 2 +- lib/warn-on-use.h | 8 +- lib/wchar.in.h | 73 +- lib/wcrtomb.c | 2 +- lib/wctype-h.c | 2 +- lib/wctype.in.h | 2 +- lib/windows-initguard.h | 2 +- lib/windows-spawn.c | 727 ++++++++++ lib/windows-spawn.h | 157 ++ lib/write.c | 2 +- lib/xalloc-oversized.h | 2 +- lib/xsize.c | 2 +- lib/xsize.h | 2 +- m4/00gnulib.m4 | 2 +- m4/__inline.m4 | 2 +- m4/absolute-header.m4 | 2 +- m4/accept4.m4 | 2 +- m4/access.m4 | 16 + m4/alloca.m4 | 12 +- m4/arpa_inet_h.m4 | 2 +- m4/autobuild.m4 | 2 +- m4/btowc.m4 | 2 +- m4/builtin-expect.m4 | 2 +- m4/byteswap.m4 | 10 +- m4/canonicalize.m4 | 2 +- m4/ceil.m4 | 2 +- m4/check-math-lib.m4 | 2 +- m4/clock_time.m4 | 20 +- m4/close.m4 | 2 +- m4/codeset.m4 | 2 +- m4/copysign.m4 | 2 +- m4/dirent_h.m4 | 2 +- m4/dirfd.m4 | 2 +- m4/double-slash-root.m4 | 2 +- m4/dup2.m4 | 2 +- m4/duplocale.m4 | 2 +- m4/eaccess.m4 | 12 + m4/eealloc.m4 | 2 +- m4/environ.m4 | 2 +- m4/errno_h.m4 | 12 +- m4/exponentd.m4 | 2 +- m4/exponentf.m4 | 2 +- m4/exponentl.m4 | 2 +- m4/extensions.m4 | 2 +- m4/extern-inline.m4 | 28 +- m4/fcntl-o.m4 | 2 +- m4/fcntl.m4 | 2 +- m4/fcntl_h.m4 | 2 +- m4/findprog-in.m4 | 11 + m4/flexmember.m4 | 2 +- m4/float_h.m4 | 22 +- m4/flock.m4 | 2 +- m4/floor.m4 | 2 +- m4/fpieee.m4 | 2 +- m4/free.m4 | 2 +- m4/frexp.m4 | 2 +- m4/fstat.m4 | 2 +- m4/fsync.m4 | 2 +- m4/func.m4 | 2 +- m4/getaddrinfo.m4 | 2 +- m4/getdtablesize.m4 | 2 +- m4/getlogin.m4 | 2 +- m4/getrandom.m4 | 2 +- m4/gettext.m4 | 383 +++++ m4/glibc2.m4 | 30 + m4/glibc21.m4 | 30 + m4/gnulib-cache.m4 | 8 +- m4/gnulib-common.m4 | 277 +++- m4/gnulib-comp.m4 | 743 ++++++---- m4/gnulib-tool.m4 | 10 +- m4/host-cpu-c-abi.m4 | 7 +- m4/hostent.m4 | 2 +- m4/iconv.m4 | 26 +- m4/iconv_h.m4 | 18 +- m4/iconv_open-utf.m4 | 2 +- m4/iconv_open.m4 | 2 +- m4/include_next.m4 | 8 +- m4/inet_ntop.m4 | 2 +- m4/inet_pton.m4 | 2 +- m4/intdiv0.m4 | 84 ++ m4/intl.m4 | 294 ++++ m4/intldir.m4 | 19 + m4/intlmacosx.m4 | 51 + m4/intmax.m4 | 33 + m4/intmax_t.m4 | 2 +- m4/inttypes-pri.m4 | 36 + m4/inttypes.m4 | 6 +- m4/inttypes_h.m4 | 2 +- m4/isfinite.m4 | 2 +- m4/isinf.m4 | 2 +- m4/isnan.m4 | 2 +- m4/isnand.m4 | 2 +- m4/isnanf.m4 | 2 +- m4/isnanl.m4 | 2 +- m4/langinfo_h.m4 | 2 +- m4/largefile.m4 | 9 +- m4/lcmessage.m4 | 31 + m4/ld-version-script.m4 | 2 +- m4/ldexp.m4 | 2 +- m4/lib-ld.m4 | 2 +- m4/lib-link.m4 | 8 +- m4/lib-prefix.m4 | 6 +- m4/libunistring.m4 | 2 +- m4/limits-h.m4 | 11 +- m4/link.m4 | 2 +- m4/localcharset.m4 | 2 +- m4/locale-fr.m4 | 2 +- m4/locale-ja.m4 | 2 +- m4/locale-zh.m4 | 2 +- m4/locale_h.m4 | 2 +- m4/localeconv.m4 | 2 +- m4/lock.m4 | 37 + m4/log.m4 | 2 +- m4/log1p.m4 | 2 +- m4/longlong.m4 | 106 ++ m4/lstat.m4 | 2 +- m4/malloc.m4 | 13 +- m4/malloca.m4 | 2 +- m4/math_h.m4 | 2 +- m4/mathfunc.m4 | 2 +- m4/mbrtowc.m4 | 2 +- m4/mbsinit.m4 | 2 +- m4/mbstate_t.m4 | 2 +- m4/mbtowc.m4 | 2 +- m4/memchr.m4 | 2 +- m4/mempcpy.m4 | 2 +- m4/minmax.m4 | 2 +- m4/mkdir.m4 | 2 +- m4/mkostemp.m4 | 2 +- m4/mktime.m4 | 31 +- m4/mmap-anon.m4 | 2 +- m4/mode_t.m4 | 2 +- m4/msvc-inval.m4 | 2 +- m4/msvc-nothrow.m4 | 2 +- m4/multiarch.m4 | 2 +- m4/netdb_h.m4 | 2 +- m4/netinet_in_h.m4 | 10 +- m4/nl_langinfo.m4 | 2 +- m4/nls.m4 | 32 + m4/nocrash.m4 | 2 +- m4/nproc.m4 | 2 +- m4/nstrftime.m4 | 2 +- m4/off_t.m4 | 2 +- m4/open-cloexec.m4 | 2 +- m4/open-slash.m4 | 2 +- m4/open.m4 | 2 +- m4/pathmax.m4 | 2 +- m4/pid_t.m4 | 2 +- m4/pipe.m4 | 2 +- m4/pipe2.m4 | 2 +- m4/po.m4 | 449 ++++++ m4/poll.m4 | 2 +- m4/poll_h.m4 | 2 +- m4/posix_spawn.m4 | 691 +++++++++ m4/printf-posix.m4 | 45 + m4/printf.m4 | 2 +- m4/progtest.m4 | 92 ++ m4/putenv.m4 | 2 +- m4/raise.m4 | 2 +- m4/rawmemchr.m4 | 2 +- m4/read.m4 | 2 +- m4/readlink.m4 | 2 +- m4/realloc.m4 | 12 +- m4/regex.m4 | 2 +- m4/rename.m4 | 2 +- m4/rmdir.m4 | 2 +- m4/round.m4 | 2 +- m4/safe-read.m4 | 2 +- m4/safe-write.m4 | 2 +- m4/sched_h.m4 | 106 ++ m4/select.m4 | 2 +- m4/servent.m4 | 2 +- m4/setenv.m4 | 2 +- m4/setlocale_null.m4 | 2 +- m4/sh-filename.m4 | 24 + m4/signal_h.m4 | 2 +- m4/signbit.m4 | 2 +- m4/size_max.m4 | 2 +- m4/snprintf.m4 | 2 +- m4/socketlib.m4 | 2 +- m4/sockets.m4 | 2 +- m4/socklen.m4 | 2 +- m4/sockpfaf.m4 | 2 +- m4/spawn_h.m4 | 151 ++ m4/ssize_t.m4 | 2 +- m4/stat-time.m4 | 2 +- m4/stat.m4 | 2 +- m4/std-gnu11.m4 | 2 +- m4/stdalign.m4 | 9 +- m4/stdbool.m4 | 124 +- m4/stddef_h.m4 | 16 +- m4/stdint.m4 | 10 +- m4/stdint_h.m4 | 2 +- m4/stdio_h.m4 | 33 +- m4/stdlib_h.m4 | 16 +- m4/stpcpy.m4 | 25 + m4/strchrnul.m4 | 50 + m4/strdup.m4 | 2 +- m4/string_h.m4 | 6 +- m4/sys_file_h.m4 | 2 +- m4/sys_random_h.m4 | 2 +- m4/sys_select_h.m4 | 2 +- m4/sys_socket_h.m4 | 9 +- m4/sys_stat_h.m4 | 8 +- m4/sys_time_h.m4 | 2 +- m4/sys_times_h.m4 | 2 +- m4/sys_types_h.m4 | 2 +- m4/sys_uio_h.m4 | 2 +- m4/tempname.m4 | 2 +- m4/threadlib.m4 | 64 +- m4/time_h.m4 | 6 +- m4/time_r.m4 | 2 +- m4/time_rz.m4 | 2 +- m4/timegm.m4 | 2 +- m4/times.m4 | 2 +- m4/tm_gmtoff.m4 | 2 +- m4/trunc.m4 | 2 +- m4/tzset.m4 | 2 +- m4/uintmax_t.m4 | 30 + m4/unistd_h.m4 | 191 +-- m4/vararrays.m4 | 72 + m4/vasnprintf.m4 | 2 +- m4/visibility.m4 | 2 +- m4/vsnprintf.m4 | 2 +- m4/warn-on-use.m4 | 2 +- m4/warnings.m4 | 2 +- m4/wchar_h.m4 | 6 +- m4/wchar_t.m4 | 2 +- m4/wcrtomb.m4 | 2 +- m4/wctype_h.m4 | 2 +- m4/wint_t.m4 | 2 +- m4/write.m4 | 2 +- m4/xsize.m4 | 2 +- m4/year2038.m4 | 12 +- m4/zzgnulib.m4 | 2 +- maint.mk | 68 +- 531 files changed, 16214 insertions(+), 3275 deletions(-) create mode 100644 lib/access.c create mode 100644 lib/concat-filename.c create mode 100644 lib/concat-filename.h create mode 100644 lib/findprog-in.c create mode 100644 lib/findprog.h create mode 100644 lib/iconv_open-zos.h create mode 100644 lib/intprops-internal.h create mode 100644 lib/inttypes.h create mode 100644 lib/malloc/.dirstamp create mode 100644 lib/malloc/dynarray-skeleton.gl.h create mode 100644 lib/malloc/dynarray.gl.h create mode 100644 lib/sched.h create mode 100644 lib/sched.in.h create mode 100644 lib/spawn.c create mode 100644 lib/spawn.h create mode 100644 lib/spawn.in.h create mode 100644 lib/spawn_int.h create mode 100644 lib/spawni.c create mode 100644 lib/spawnp.c create mode 100644 lib/stdbool.h create mode 100644 lib/stdckdint.h create mode 100644 lib/stdckdint.in.h create mode 100644 lib/stdio-read.c create mode 100644 lib/stdio-write.c create mode 100644 lib/stpcpy.c create mode 100644 lib/strchrnul.c create mode 100644 lib/strchrnul.valgrind create mode 100644 lib/windows-spawn.c create mode 100644 lib/windows-spawn.h create mode 100644 m4/access.m4 create mode 100644 m4/eaccess.m4 create mode 100644 m4/findprog-in.m4 create mode 100644 m4/gettext.m4 create mode 100644 m4/glibc2.m4 create mode 100644 m4/glibc21.m4 create mode 100644 m4/intdiv0.m4 create mode 100644 m4/intl.m4 create mode 100644 m4/intldir.m4 create mode 100644 m4/intlmacosx.m4 create mode 100644 m4/intmax.m4 create mode 100644 m4/inttypes-pri.m4 create mode 100644 m4/lcmessage.m4 create mode 100644 m4/lock.m4 create mode 100644 m4/longlong.m4 create mode 100644 m4/nls.m4 create mode 100644 m4/po.m4 create mode 100644 m4/posix_spawn.m4 create mode 100644 m4/printf-posix.m4 create mode 100644 m4/progtest.m4 create mode 100644 m4/sched_h.m4 create mode 100644 m4/sh-filename.m4 create mode 100644 m4/spawn_h.m4 create mode 100644 m4/stpcpy.m4 create mode 100644 m4/strchrnul.m4 create mode 100644 m4/uintmax_t.m4 create mode 100644 m4/vararrays.m4 diff --git a/GNUmakefile b/GNUmakefile index 0c99d5842..7a08c9d55 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -5,7 +5,7 @@ # It is necessary if you want to build targets usually of interest # only to the maintainer. -# Copyright (C) 2001, 2003, 2006-2021 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2006-2022 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/build-aux/announce-gen b/build-aux/announce-gen index f3b5461ae..3847a568d 100755 --- a/build-aux/announce-gen +++ b/build-aux/announce-gen @@ -3,7 +3,7 @@ # Generate a release announcement message. -# Copyright (C) 2002-2021 Free Software Foundation, Inc. +# Copyright (C) 2002-2022 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,13 +35,13 @@ eval 'exec perl -wSx "$0" "$@"' if 0; -my $VERSION = '2021-08-04 09:17'; # UTC +my $VERSION = '2022-07-10 01:47'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook # do its job. Otherwise, update this string manually. -my $copyright_year = '2021'; +my $copyright_year = '2022'; use strict; use Getopt::Long; @@ -90,6 +90,10 @@ The following are optional: VERSION is the result of running git describe in the gnulib source directory. required if gnulib is in TOOL_LIST. + --gpg-key-email=EMAIL The email address of the key used to + sign the tarballs + --gpg-keyring-url=URL URL pointing to keyring containing the key used + to sign the tarballs --no-print-checksums do not emit SHA1 or SHA256 checksums --archive-suffix=SUF add SUF to the list of archive suffixes --mail-headers=HEADERS a space-separated list of mail headers, e.g., @@ -377,6 +381,8 @@ sub get_tool_versions ($$) my $bootstrap_tools; my $gnulib_version; my $print_checksums_p = 1; + my $gpg_key_email; + my $gpg_keyring_url; # Reformat the warnings before displaying them. local $SIG{__WARN__} = sub @@ -395,6 +401,8 @@ sub get_tool_versions ($$) 'previous-version=s' => \$prev_version, 'current-version=s' => \$curr_version, 'gpg-key-id=s' => \$gpg_key_id, + 'gpg-key-email=s' => \$gpg_key_email, + 'gpg-keyring-url=s' => \$gpg_keyring_url, 'url-directory=s' => \@url_dir_list, 'news=s' => \@news_file, 'srcdir=s' => \$srcdir, @@ -437,11 +445,15 @@ sub get_tool_versions ($$) my @tool_list = split ',', $bootstrap_tools if $bootstrap_tools; - grep (/^gnulib$/, @tool_list) ^ defined $gnulib_version + grep (/^gnulib$/, @tool_list) && ! defined $gnulib_version and (warn "when specifying gnulib as a tool, you must also specify\n" . "--gnulib-version=V, where V is the result of running git describe\n" . "in the gnulib source directory.\n"), $fail = 1; + ! grep (/^gnulib$/, @tool_list) && defined $gnulib_version + and (warn "with --gnulib-version=V you must use --bootstrap-tools=...\n" + . "including gnulib in that list"), $fail = 1; + !$release_type || exists $valid_release_types{$release_type} or (warn "'$release_type': invalid release type\n"), $fail = 1; @@ -490,7 +502,7 @@ EOF { # When there's only one tarball and one URL, use a more concise form. my $m = "$url_dir_list[0]/$tarballs[0]"; - print "Here are the compressed sources and a GPG detached signature[*]:\n" + print "Here are the compressed sources and a GPG detached signature:\n" . " $m\n" . " $m.sig\n\n"; } @@ -502,7 +514,7 @@ EOF . "please tell bug-gnulib\@gnu.org)", @url_dir_list, %size, $xd); my @sig_files = map { "$_.sig" } @tarballs; - print_locations ("GPG detached signatures[*]", @url_dir_list, %size, + print_locations ("GPG detached signatures", @url_dir_list, %size, @sig_files); } @@ -527,18 +539,55 @@ EOF and print_checksums (@sizable); print <"$outdir/$PACKAGE.txt.gz" @@ -341,7 +341,7 @@ html_split() { opt="--split=$1 --node-files $commonarg $htmlarg" cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\"" - printf "\nGenerating html by $1... ($cmd)\n" + printf "\nGenerating html by %s... (%s)\n" "$1" "$cmd" eval "$cmd" split_html_dir=$PACKAGE.html ( @@ -359,7 +359,7 @@ html_split() if test -z "$use_texi2html"; then opt="--no-split --html -o $PACKAGE.html $commonarg $htmlarg" cmd="$SETLANG $MAKEINFO $opt \"$srcfile\"" - printf "\nGenerating monolithic html... ($cmd)\n" + printf "\nGenerating monolithic html... (%s)\n" "$cmd" rm -rf $PACKAGE.html # in case a directory is left over eval "$cmd" html_mono_size=`calcsize $PACKAGE.html` @@ -380,7 +380,7 @@ if test -z "$use_texi2html"; then # opt="--html -o $PACKAGE.html $split_arg $commonarg $htmlarg" cmd="$SETLANG $MAKEINFO $opt \"$srcfile\"" - printf "\nGenerating html by $split... ($cmd)\n" + printf "\nGenerating html by %s... (%s)\n" "$split" "$cmd" eval "$cmd" split_html_dir=$PACKAGE.html copy_images $split_html_dir/ $split_html_dir/*.html @@ -398,7 +398,7 @@ if test -z "$use_texi2html"; then else # use texi2html: opt="--output $PACKAGE.html $commonarg $htmlarg" cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\"" - printf "\nGenerating monolithic html with texi2html... ($cmd)\n" + printf "\nGenerating monolithic html with texi2html... (%s)\n" "$cmd" rm -rf $PACKAGE.html # in case a directory is left over eval "$cmd" html_mono_size=`calcsize $PACKAGE.html` @@ -428,7 +428,7 @@ texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"` if test -n "$docbook"; then opt="-o - --docbook $commonarg" cmd="$SETLANG $MAKEINFO $opt \"$srcfile\" >${srcdir}/$PACKAGE-db.xml" - printf "\nGenerating docbook XML... ($cmd)\n" + printf "\nGenerating docbook XML... (%s)\n" "$cmd" eval "$cmd" docbook_xml_size=`calcsize $PACKAGE-db.xml` gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz" @@ -438,7 +438,7 @@ if test -n "$docbook"; then split_html_db_dir=html_node_db opt="$commonarg -o $split_html_db_dir" cmd="$DOCBOOK2HTML $opt \"${outdir}/$PACKAGE-db.xml\"" - printf "\nGenerating docbook HTML... ($cmd)\n" + printf "\nGenerating docbook HTML... (%s)\n" "$cmd" eval "$cmd" ( cd ${split_html_db_dir} || exit 1 @@ -451,20 +451,20 @@ if test -n "$docbook"; then rmdir ${split_html_db_dir} cmd="$DOCBOOK2TXT \"${outdir}/$PACKAGE-db.xml\"" - printf "\nGenerating docbook ASCII... ($cmd)\n" + printf "\nGenerating docbook ASCII... (%s)\n" "$cmd" eval "$cmd" docbook_ascii_size=`calcsize $PACKAGE-db.txt` mv $PACKAGE-db.txt "$outdir/" cmd="$DOCBOOK2PDF \"${outdir}/$PACKAGE-db.xml\"" - printf "\nGenerating docbook PDF... ($cmd)\n" + printf "\nGenerating docbook PDF... (%s)\n" "$cmd" eval "$cmd" docbook_pdf_size=`calcsize $PACKAGE-db.pdf` mv $PACKAGE-db.pdf "$outdir/" fi # -printf "\nMaking index.html for $PACKAGE...\n" +printf "\nMaking index.html for %s...\n" "$PACKAGE" if test -z "$use_texi2html"; then CONDS="/%%IF *HTML_SECTION%%/,/%%ENDIF *HTML_SECTION%%/d;\ /%%IF *HTML_CHAPTER%%/,/%%ENDIF *HTML_CHAPTER%%/d" diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 5e42afb2c..36c1abaf7 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -1,12 +1,12 @@ #!/bin/sh # Print a version string. -scriptversion=2019-10-13.15; # UTC +scriptversion=2022-07-09.08; # UTC -# Copyright (C) 2007-2021 Free Software Foundation, Inc. +# Copyright (C) 2007-2022 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -65,9 +65,10 @@ scriptversion=2019-10-13.15; # UTC # EXTRA_DIST = $(top_srcdir)/.version # BUILT_SOURCES = $(top_srcdir)/.version # $(top_srcdir)/.version: -# echo $(VERSION) > $@-t && mv $@-t $@ +# echo '$(VERSION)' > $@-t +# mv $@-t $@ # dist-hook: -# echo $(VERSION) > $(distdir)/.tarball-version +# echo '$(VERSION)' > $(distdir)/.tarball-version me=$0 @@ -94,7 +95,7 @@ Options: --help display this help and exit --version output version information and exit -Running without arguments will suffice in most cases." +Send patches and bug reports to ." prefix=v fallback= diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog index 9ff15f601..82d9f9733 100755 --- a/build-aux/gitlog-to-changelog +++ b/build-aux/gitlog-to-changelog @@ -3,7 +3,7 @@ # Convert git log output to ChangeLog format. -# Copyright (C) 2008-2021 Free Software Foundation, Inc. +# Copyright (C) 2008-2022 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ eval 'exec perl -wSx "$0" "$@"' if 0; -my $VERSION = '2021-02-24 23:42'; # UTC +my $VERSION = '2022-01-27 18:49'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook diff --git a/build-aux/gnu-web-doc-update b/build-aux/gnu-web-doc-update index cc553f9a3..c041364fb 100755 --- a/build-aux/gnu-web-doc-update +++ b/build-aux/gnu-web-doc-update @@ -2,9 +2,9 @@ # Run this after each non-alpha release, to update the web documentation at # https://www.gnu.org/software/$pkg/manual/ -VERSION=2021-01-09.09; # UTC +VERSION=2022-01-27.18; # UTC -# Copyright (C) 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2009-2022 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/build-aux/gnupload b/build-aux/gnupload index e7822aed7..b97e566f9 100755 --- a/build-aux/gnupload +++ b/build-aux/gnupload @@ -1,9 +1,9 @@ #!/bin/sh # Sign files and upload them. -scriptversion=2021-04-11.09; # UTC +scriptversion=2022-01-27.18; # UTC -# Copyright (C) 2004-2021 Free Software Foundation, Inc. +# Copyright (C) 2004-2022 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free index 5bbbc44c5..1a027a5d5 100755 --- a/build-aux/useless-if-before-free +++ b/build-aux/useless-if-before-free @@ -4,7 +4,7 @@ # Detect instances of "if (p) free (p);". # Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces. -# Copyright (C) 2008-2021 Free Software Foundation, Inc. +# Copyright (C) 2008-2022 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -36,13 +36,13 @@ eval 'exec perl -wSx "$0" "$@"' if 0; -my $VERSION = '2021-04-11 10:11'; # UTC +my $VERSION = '2022-01-27 18:51'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook # do its job. Otherwise, update this string manually. -my $copyright_year = '2021'; +my $copyright_year = '2022'; use strict; use warnings; diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files index cf168ea83..77750b9f8 100755 --- a/build-aux/vc-list-files +++ b/build-aux/vc-list-files @@ -4,7 +4,7 @@ # Print a version string. scriptversion=2018-03-07.03; # UTC -# Copyright (C) 2006-2021 Free Software Foundation, Inc. +# Copyright (C) 2006-2022 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/doc/gendocs_template b/doc/gendocs_template index cd9ac3831..0415d947b 100644 --- a/doc/gendocs_template +++ b/doc/gendocs_template @@ -2,7 +2,7 @@ install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 2) GNU gettext has been found in the system's C library. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 3) No internationalization, always use English msgid. +dnl Catalog format: none +dnl Catalog extension: none +dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. +dnl The use of .gmo is historical (it was needed to avoid overwriting the +dnl GNU format catalogs when building on a platform with an X/Open gettext), +dnl but we keep it in order not to force irrelevant filename changes on the +dnl maintainers. +dnl +AC_DEFUN([AM_GNU_GETTEXT], +[ + dnl Argument checking. + ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , + [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT +])])])])]) + ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], + [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) + ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , + [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT +])])])]) + define([gt_included_intl], + ifelse([$1], [external], + ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), + [yes])) + define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) + gt_NEEDS_INIT + AM_GNU_GETTEXT_NEED([$2]) + + AC_REQUIRE([AM_PO_SUBDIRS])dnl + ifelse(gt_included_intl, yes, [ + AC_REQUIRE([AM_INTL_SUBDIR])dnl + ]) + + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Sometimes libintl requires libiconv, so first search for libiconv. + dnl Ideally we would do this search only after the + dnl if test "$USE_NLS" = "yes"; then + dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT + dnl the configure script would need to contain the same shell code + dnl again, outside any 'if'. There are two solutions: + dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. + dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. + dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not + dnl documented, we avoid it. + ifelse(gt_included_intl, yes, , [ + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + ]) + + dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. + gt_INTL_MACOSX + + dnl Set USE_NLS. + AC_REQUIRE([AM_NLS]) + + ifelse(gt_included_intl, yes, [ + BUILD_INCLUDED_LIBINTL=no + USE_INCLUDED_LIBINTL=no + ]) + LIBINTL= + LTLIBINTL= + POSUB= + + dnl Add a version number to the cache macros. + case " $gt_needs " in + *" need-formatstring-macros "*) gt_api_version=3 ;; + *" need-ngettext "*) gt_api_version=2 ;; + *) gt_api_version=1 ;; + esac + gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" + gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + ifelse(gt_included_intl, yes, [ + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH([included-gettext], + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + ]) + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If GNU gettext is available we use this. Else we have + dnl to fall back to GNU NLS library. + + if test $gt_api_version -ge 3; then + gt_revision_test_code=' +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +' + else + gt_revision_test_code= + fi + if test $gt_api_version -ge 2; then + gt_expression_test_code=' + * ngettext ("", "", 0)' + else + gt_expression_test_code= + fi + + AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], + [AC_TRY_LINK([#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings;], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], + [eval "$gt_func_gnugettext_libc=yes"], + [eval "$gt_func_gnugettext_libc=no"])]) + + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + dnl Sometimes libintl requires libiconv, so first search for libiconv. + ifelse(gt_included_intl, yes, , [ + AM_ICONV_LINK + ]) + dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL + dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) + dnl because that would add "-liconv" to LIBINTL and LTLIBINTL + dnl even if libiconv doesn't exist. + AC_LIB_LINKFLAGS_BODY([intl]) + AC_CACHE_CHECK([for GNU gettext in libintl], + [$gt_func_gnugettext_libintl], + [gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + dnl Now see whether libintl exists and does not depend on libiconv. + AC_TRY_LINK([#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *);], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], + [eval "$gt_func_gnugettext_libintl=yes"], + [eval "$gt_func_gnugettext_libintl=no"]) + dnl Now see whether libintl exists and depends on libiconv. + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *);], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + eval "$gt_func_gnugettext_libintl=yes" + ]) + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS"]) + fi + + dnl If an already present or preinstalled GNU gettext() is found, + dnl use it. But if this macro is used in GNU gettext, and GNU + dnl gettext is already preinstalled in libintl, we update this + dnl libintl. (Cf. the install rule in intl/Makefile.in.) + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ + || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + dnl Reset the values set by searching for libintl. + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + ifelse(gt_included_intl, yes, [ + if test "$gt_use_preinstalled_gnugettext" != "yes"; then + dnl GNU gettext is not found in the C library. + dnl Fall back on included GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + BUILD_INCLUDED_LIBINTL=yes + USE_INCLUDED_LIBINTL=yes + LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" + LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" + LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` + fi + + CATOBJEXT= + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions to use GNU gettext tools. + CATOBJEXT=.gmo + fi + ]) + + if test -n "$INTL_MACOSX_LIBS"; then + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Some extra flags are needed during linking. + LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" + LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" + fi + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + AC_DEFINE([ENABLE_NLS], [1], + [Define to 1 if translation of program messages to the user's native language + is requested.]) + else + USE_NLS=no + fi + fi + + AC_MSG_CHECKING([whether to use NLS]) + AC_MSG_RESULT([$USE_NLS]) + if test "$USE_NLS" = "yes"; then + AC_MSG_CHECKING([where the gettext function comes from]) + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + AC_MSG_RESULT([$gt_source]) + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + AC_MSG_CHECKING([how to link with libintl]) + AC_MSG_RESULT([$LIBINTL]) + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) + fi + + dnl For backward compatibility. Some packages may be using this. + AC_DEFINE([HAVE_GETTEXT], [1], + [Define if the GNU gettext() function is already present or preinstalled.]) + AC_DEFINE([HAVE_DCGETTEXT], [1], + [Define if the GNU dcgettext() function is already present or preinstalled.]) + fi + + dnl We need to process the po/ directory. + POSUB=po + fi + + ifelse(gt_included_intl, yes, [ + dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL + dnl to 'yes' because some of the testsuite requires it. + if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then + BUILD_INCLUDED_LIBINTL=yes + fi + + dnl Make all variables we use known to autoconf. + AC_SUBST([BUILD_INCLUDED_LIBINTL]) + AC_SUBST([USE_INCLUDED_LIBINTL]) + AC_SUBST([CATOBJEXT]) + + dnl For backward compatibility. Some configure.ins may be using this. + nls_cv_header_intl= + nls_cv_header_libgt= + + dnl For backward compatibility. Some Makefiles may be using this. + DATADIRNAME=share + AC_SUBST([DATADIRNAME]) + + dnl For backward compatibility. Some Makefiles may be using this. + INSTOBJEXT=.mo + AC_SUBST([INSTOBJEXT]) + + dnl For backward compatibility. Some Makefiles may be using this. + GENCAT=gencat + AC_SUBST([GENCAT]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLOBJS= + if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLOBJS="\$(GETTOBJS)" + fi + AC_SUBST([INTLOBJS]) + + dnl Enable libtool support if the surrounding package wishes it. + INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix + AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) + ]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLLIBS="$LIBINTL" + AC_SUBST([INTLLIBS]) + + dnl Make all documented variables known to autoconf. + AC_SUBST([LIBINTL]) + AC_SUBST([LTLIBINTL]) + AC_SUBST([POSUB]) +]) + + +dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. +m4_define([gt_NEEDS_INIT], +[ + m4_divert_text([DEFAULTS], [gt_needs=]) + m4_define([gt_NEEDS_INIT], []) +]) + + +dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) +AC_DEFUN([AM_GNU_GETTEXT_NEED], +[ + m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) +]) + + +dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) +AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) diff --git a/m4/glibc2.m4 b/m4/glibc2.m4 new file mode 100644 index 000000000..f148c12c4 --- /dev/null +++ b/m4/glibc2.m4 @@ -0,0 +1,30 @@ +# glibc2.m4 serial 2 +dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Test for the GNU C Library, version 2.0 or newer. +# From Bruno Haible. + +AC_DEFUN([gt_GLIBC2], + [ + AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer], + [ac_cv_gnu_library_2], + [AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ >= 2) + Lucky GNU user + #endif +#endif + ], + [ac_cv_gnu_library_2=yes], + [ac_cv_gnu_library_2=no]) + ] + ) + AC_SUBST([GLIBC2]) + GLIBC2="$ac_cv_gnu_library_2" + ] +) diff --git a/m4/glibc21.m4 b/m4/glibc21.m4 new file mode 100644 index 000000000..68ada9d4d --- /dev/null +++ b/m4/glibc21.m4 @@ -0,0 +1,30 @@ +# glibc21.m4 serial 4 +dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Test for the GNU C Library, version 2.1 or newer. +# From Bruno Haible. + +AC_DEFUN([gl_GLIBC21], + [ + AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer], + [ac_cv_gnu_library_2_1], + [AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) + Lucky GNU user + #endif +#endif + ], + [ac_cv_gnu_library_2_1=yes], + [ac_cv_gnu_library_2_1=no]) + ] + ) + AC_SUBST([GLIBC21]) + GLIBC21="$ac_cv_gnu_library_2_1" + ] +) diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 9e6b41b4a..7d6f43ab7 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -1,8 +1,8 @@ -# Copyright (C) 2002-2021 Free Software Foundation, Inc. +# Copyright (C) 2002-2022 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This file is distributed in the hope that it will be useful, @@ -115,6 +115,7 @@ # pipe-posix \ # pipe2 \ # poll \ +# posix_spawnp \ # putenv \ # readlink \ # recv \ @@ -214,6 +215,7 @@ gl_MODULES([ pipe-posix pipe2 poll + posix_spawnp putenv readlink recv @@ -242,7 +244,7 @@ gl_MODULES([ warnings wchar ]) -gl_AVOID([ lock unistr/base unistr/u8-mbtouc unistr/u8-mbtouc-unsafe unistr/u8-mbtoucr unistr/u8-prev unistr/u8-uctomb unitypes]) +gl_AVOID([lock unistr/base unistr/u8-mbtouc unistr/u8-mbtouc-unsafe unistr/u8-mbtoucr unistr/u8-prev unistr/u8-uctomb unitypes]) gl_SOURCE_BASE([lib]) gl_M4_BASE([m4]) gl_PO_BASE([]) diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index c801b3de9..8a5daa230 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,5 +1,5 @@ -# gnulib-common.m4 serial 67 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +# gnulib-common.m4 serial 73 +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -69,7 +69,9 @@ AC_DEFUN([gl_COMMON_BODY], [ [/* Attributes. */ #if (defined __has_attribute \ && (!defined __clang_minor__ \ - || 3 < __clang_major__ + (5 <= __clang_minor__))) + || (defined __apple_build_version__ \ + ? 6000000 <= __apple_build_version__ \ + : 3 < __clang_major__ + (5 <= __clang_minor__)))) # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) #else # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr @@ -104,6 +106,10 @@ AC_DEFUN([gl_COMMON_BODY], [ #endif #ifdef __has_c_attribute +# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710 \ + && _GL_GNUC_PREREQ (4, 6)) +# pragma GCC diagnostic ignored "-Wpedantic" +# endif # define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__) #else # define _GL_HAS_C_ATTRIBUTE(attr) 0 @@ -111,24 +117,39 @@ AC_DEFUN([gl_COMMON_BODY], [ ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead. [ +/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function + is the size of the returned memory block. + _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied + by the Nth argument of the function is the size of the returned memory block. + */ +/* Applies to: function, pointer to function, function types. */ #if _GL_HAS_ATTRIBUTE (alloc_size) # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) #else # define _GL_ATTRIBUTE_ALLOC_SIZE(args) #endif +/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the + function and report an error if it cannot do so. */ +/* Applies to: function. */ #if _GL_HAS_ATTRIBUTE (always_inline) # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) #else # define _GL_ATTRIBUTE_ALWAYS_INLINE #endif +/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show + in stack traces when debugging. The compiler should omit the function from + stack traces. */ +/* Applies to: function. */ #if _GL_HAS_ATTRIBUTE (artificial) # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) #else # define _GL_ATTRIBUTE_ARTIFICIAL #endif +/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */ +/* Applies to: functions. */ /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at . Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */ @@ -142,25 +163,45 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_COLD #endif +/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate + calls to the function with the same arguments. + This attribute is safe for a function that neither depends on nor affects + observable state, and always returns exactly once - e.g., does not loop + forever, and does not call longjmp. + (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (const) # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) #else # define _GL_ATTRIBUTE_CONST #endif -/* _GL_ATTRIBUTE_DEALLOC (F, I) is for functions returning pointers +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers that can be freed by passing them as the Ith argument to the - function F. _GL_ATTRIBUTE_DEALLOC_FREE is for functions that - return pointers that can be freed via 'free'; it can be used - only after including stdlib.h. These macros cannot be used on - inline functions. */ + function F. + _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after declaring 'free'. */ +/* Applies to: functions. Cannot be used on inline functions. */ #if _GL_GNUC_PREREQ (11, 0) # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) #else # define _GL_ATTRIBUTE_DEALLOC(f, i) #endif -#define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) +/* If gnulib's or has already defined this macro, continue + to use this earlier definition, since may not have been included + yet. */ +#ifndef _GL_ATTRIBUTE_DEALLOC_FREE +# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) +#endif +/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated. + The compiler may warn if the entity is used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: namespace, class, template specialization. */ #if _GL_HAS_C_ATTRIBUTE (deprecated) # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] #elif _GL_HAS_ATTRIBUTE (deprecated) @@ -169,6 +210,11 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_DEPRECATED #endif +/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and + the function call is not optimized away. + _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and + the function call is not optimized away. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (error) # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) @@ -180,13 +226,20 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_WARNING(msg) #endif +/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain + visible to debuggers etc., even with '-fwhole-program'. */ +/* Applies to: functions, variables. */ #if _GL_HAS_ATTRIBUTE (externally_visible) # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible)) #else # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE #endif -/* FALLTHROUGH is special, because it always expands to something. */ +/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if + the control flow falls through to the immediately following 'case' or + 'default' label. The compiler should not warn in this case. */ +/* Applies to: Empty statement (;), inside a 'switch' statement. */ +/* Always expands to something. */ #if _GL_HAS_C_ATTRIBUTE (fallthrough) # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] #elif _GL_HAS_ATTRIBUTE (fallthrough) @@ -195,24 +248,47 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) #endif +/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) + declares that the STRING-INDEXth function argument is a format string of + style ARCHETYPE, which is one of: + printf, gnu_printf + scanf, gnu_scanf, + strftime, gnu_strftime, + strfmon, + or the same thing prefixed and suffixed with '__'. + If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK + are suitable for the format string. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (format) # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) #else # define _GL_ATTRIBUTE_FORMAT(spec) #endif +/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other + compilation unit, it executes code from that unit only by return or by + exception handling. This declaration lets the compiler optimize that unit + more aggressively. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (leaf) # define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) #else # define _GL_ATTRIBUTE_LEAF #endif +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (malloc) # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) #else # define _GL_ATTRIBUTE_MALLOC #endif +/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the + same storage as pointers to other types. Thus this declaration disables + strict aliasing optimization. */ +/* Applies to: types. */ /* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */ #if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C # define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) @@ -220,14 +296,33 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_MAY_ALIAS #endif +/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if + the entity is not used. The compiler should not warn if the entity is not + used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: class. */ +/* In C++ and C2x, this is spelled [[__maybe_unused__]]. + GCC's syntax is __attribute__ ((__unused__)). + clang supports both syntaxes. */ #if _GL_HAS_C_ATTRIBUTE (maybe_unused) # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] #else # define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED #endif +/* Alternative spelling of this macro, for convenience and for + compatibility with glibc/include/libc-symbols.h. */ +#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED /* Earlier spellings of this macro. */ #define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED +/* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not + discard the return value. The compiler may warn if the caller does not use + the return value, unless the caller uses something like ignore_value. */ +/* Applies to: function, enumeration, class. */ #if _GL_HAS_C_ATTRIBUTE (nodiscard) # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] #elif _GL_HAS_ATTRIBUTE (warn_unused_result) @@ -236,18 +331,30 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_NODISCARD #endif +/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the + function. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (noinline) # define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) #else # define _GL_ATTRIBUTE_NOINLINE #endif +/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,... + must not be NULL. + _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be + null. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (nonnull) # define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) #else # define _GL_ATTRIBUTE_NONNULL(args) #endif +/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is + not meant to be NUL-terminated. */ +/* Applies to: struct/union members and variables that are arrays of element + type '[[un]signed] char'. */ #if _GL_HAS_ATTRIBUTE (nonstring) # define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) #else @@ -256,48 +363,76 @@ AC_DEFUN([gl_COMMON_BODY], [ /* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */ +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) #else # define _GL_ATTRIBUTE_NOTHROW #endif +/* _GL_ATTRIBUTE_PACKED declares: + For struct members: The member has the smallest possible alignment. + For struct, union, class: All members have the smallest possible alignment, + minimizing the memory required. */ +/* Applies to: struct members, struct, union, + in C++ also: class. */ #if _GL_HAS_ATTRIBUTE (packed) # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) #else # define _GL_ATTRIBUTE_PACKED #endif +/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate + calls to the function with the same arguments if observable state is not + changed between calls. + This attribute is safe for a function that does not affect + observable state, and always returns exactly once. + (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (pure) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else # define _GL_ATTRIBUTE_PURE #endif +/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is + a non-NULL pointer. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (returns_nonnull) # define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) #else # define _GL_ATTRIBUTE_RETURNS_NONNULL #endif +/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a + trailing NULL argument. + _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99). + _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ +/* Applies to: functions. */ #if _GL_HAS_ATTRIBUTE (sentinel) # define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) #else # define _GL_ATTRIBUTE_SENTINEL(pos) #endif +/* A helper macro. Don't use it directly. */ #if _GL_HAS_ATTRIBUTE (unused) # define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #else # define _GL_ATTRIBUTE_UNUSED #endif -/* Earlier spellings of this macro. */ -#define _GL_UNUSED _GL_ATTRIBUTE_UNUSED ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead. [ -/* To support C++ as well as C, use _GL_UNUSED_LABEL with trailing ';'. */ -#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5) +/* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the + immediately preceding label is not used. The compiler should not warn + if the label is not used. */ +/* Applies to: label (both in C and C++). */ +/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;' + syntax. But clang does. */ +#if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__ # define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED #else # define _GL_UNUSED_LABEL @@ -690,6 +825,24 @@ AC_DEFUN([gl_CACHE_VAL_SILENT], ]) ]) +# gl_CONDITIONAL(conditional, condition) +# is like AM_CONDITIONAL(conditional, condition), except that it does not +# produce an error +# configure: error: conditional "..." was never defined. +# Usually this means the macro was only invoked conditionally. +# when only invoked conditionally. Instead, in that case, both the _TRUE +# and the _FALSE case are disabled. +AC_DEFUN([gl_CONDITIONAL], +[ + pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl + AM_CONDITIONAL([$1], [$2]) + popdef([AC_CONFIG_COMMANDS_PRE])dnl + if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then + [$1]_TRUE='#' + [$1]_FALSE='#' + fi +]) + # gl_CC_ALLOW_WARNINGS # sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option # that reverts a preceding '-Werror' option, if available. @@ -756,6 +909,102 @@ AC_DEFUN([gl_CXX_ALLOW_WARNINGS], AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS]) ]) +# gl_CC_GNULIB_WARNINGS +# sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option +# set that enables or disables warnings as suitable for the Gnulib coding style. +AC_DEFUN([gl_CC_GNULIB_WARNINGS], +[ + AC_REQUIRE([gl_CC_ALLOW_WARNINGS]) + dnl Assume that the compiler supports -Wno-* options only if it also supports + dnl -Wno-error. + GL_CFLAG_GNULIB_WARNINGS='' + if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then + dnl Enable these warning options: + dnl + dnl GCC clang + dnl -Wno-cast-qual >= 3 >= 3.9 + dnl -Wno-conversion >= 3 >= 3.9 + dnl -Wno-float-conversion >= 4.9 >= 3.9 + dnl -Wno-float-equal >= 3 >= 3.9 + dnl -Wimplicit-fallthrough >= 7 >= 3.9 + dnl -Wno-pedantic >= 4.8 >= 3.9 + dnl -Wno-sign-compare >= 3 >= 3.9 + dnl -Wno-sign-conversion >= 4.3 >= 3.9 + dnl -Wno-type-limits >= 4.3 >= 3.9 + dnl -Wno-undef >= 3 >= 3.9 + dnl -Wno-unsuffixed-float-constants >= 4.5 + dnl -Wno-unused-function >= 3 >= 3.9 + dnl -Wno-unused-parameter >= 3 >= 3.9 + dnl + cat > conftest.c <<\EOF + #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-cast-qual + -Wno-conversion + -Wno-float-equal + -Wno-sign-compare + -Wno-undef + -Wno-unused-function + -Wno-unused-parameter + #endif + #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-float-conversion + #endif + #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wimplicit-fallthrough + #endif + #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-pedantic + #endif + #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-sign-conversion + -Wno-type-limits + #endif + #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4 + -Wno-unsuffixed-float-constants + #endif +EOF + gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out" + if AC_TRY_EVAL([gl_command]); then + gl_options=`grep -v '#' conftest.out` + for word in $gl_options; do + GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word" + done + fi + rm -f conftest.c conftest.out + fi + AC_SUBST([GL_CFLAG_GNULIB_WARNINGS]) +]) + +dnl gl_CONDITIONAL_HEADER([foo.h]) +dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input +dnl and produces +dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based +dnl on whether GL_GENERATE_FOO_H is true or false, +dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of +dnl the shell variable GL_GENERATE_FOO_H. +AC_DEFUN([gl_CONDITIONAL_HEADER], +[ + m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1))) + m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1))) + m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1))) + case "$gl_generate_var" in + false) gl_header_name='' ;; + true) + dnl It is OK to use a .h file in lib/ from within tests/, but not vice + dnl versa. + if test -z "$gl_header_name"; then + gl_header_name="${gl_source_base_prefix}$1" + fi + ;; + *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;; + esac + AC_SUBST(gl_header_name) + gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var]) + m4_popdef([gl_generate_cond]) + m4_popdef([gl_generate_var]) + m4_popdef([gl_header_name]) +]) + dnl Expands to some code for use in .c programs that, on native Windows, defines dnl the Microsoft deprecated alias function names to the underscore-prefixed dnl actual function names. With this macro, these function names are available diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 0ae96ead7..f286cfc9d 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -1,9 +1,9 @@ # DO NOT EDIT! GENERATED AUTOMATICALLY! -# Copyright (C) 2002-2021 Free Software Foundation, Inc. +# Copyright (C) 2002-2022 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This file is distributed in the hope that it will be useful, @@ -42,10 +42,10 @@ AC_DEFUN([gl_EARLY], AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_REQUIRE([gl_PROG_AR_RANLIB]) - AC_REQUIRE([AM_PROG_CC_C_O]) # Code from module absolute-header: # Code from module accept: # Code from module accept4: + # Code from module access: # Code from module alignof: # Code from module alloca: # Code from module alloca-opt: @@ -71,6 +71,7 @@ AC_DEFUN([gl_EARLY], # Code from module clock-time: # Code from module cloexec: # Code from module close: + # Code from module concat-filename: # Code from module connect: # Code from module copysign: # Code from module dirent: @@ -89,6 +90,7 @@ AC_DEFUN([gl_EARLY], # Code from module fcntl-h: # Code from module fd-hook: # Code from module filename: + # Code from module findprog-in: # Code from module flexmember: # Code from module float: # Code from module flock: @@ -102,6 +104,7 @@ AC_DEFUN([gl_EARLY], # Code from module full-read: # Code from module full-write: # Code from module func: + # Code from module gen-header: # Code from module gendocs: # Code from module getaddrinfo: # Code from module getdtablesize: @@ -187,6 +190,8 @@ AC_DEFUN([gl_EARLY], # Code from module pipe2: # Code from module poll: # Code from module poll-h: + # Code from module posix_spawn-internal: + # Code from module posix_spawnp: # Code from module putenv: # Code from module raise: # Code from module rawmemchr: @@ -202,6 +207,7 @@ AC_DEFUN([gl_EARLY], # Code from module safe-read: # Code from module safe-write: # Code from module same-inode: + # Code from module sched: # Code from module scratch_buffer: # Code from module select: # Code from module send: @@ -210,6 +216,7 @@ AC_DEFUN([gl_EARLY], # Code from module setenv: # Code from module setlocale-null: # Code from module setsockopt: + # Code from module sh-filename: # Code from module shutdown: # Code from module signal-h: # Code from module signbit: @@ -223,16 +230,20 @@ AC_DEFUN([gl_EARLY], # Code from module socketlib: # Code from module sockets: # Code from module socklen: + # Code from module spawn: # Code from module ssize_t: # Code from module stat: # Code from module stat-time: # Code from module std-gnu11: # Code from module stdalign: # Code from module stdbool: + # Code from module stdckdint: # Code from module stddef: # Code from module stdint: # Code from module stdio: # Code from module stdlib: + # Code from module stpcpy: + # Code from module strchrnul: # Code from module strdup-posix: # Code from module streq: # Code from module striconveh: @@ -257,6 +268,7 @@ AC_DEFUN([gl_EARLY], # Code from module unistd: # Code from module unsetenv: # Code from module useless-if-before-free: + # Code from module vararrays: # Code from module vasnprintf: # Code from module vc-list-files: # Code from module verify: @@ -265,6 +277,7 @@ AC_DEFUN([gl_EARLY], # Code from module wchar: # Code from module wcrtomb: # Code from module wctype-h: + # Code from module windows-spawn: # Code from module write: # Code from module xalloc-oversized: # Code from module xsize: @@ -274,6 +287,7 @@ AC_DEFUN([gl_EARLY], # "Check for header files, types and library functions". AC_DEFUN([gl_INIT], [ + AC_CONFIG_LIBOBJ_DIR([lib]) AM_CONDITIONAL([GL_COND_LIBTOOL], [true]) gl_cond_libtool=true gl_m4_base='m4' @@ -286,97 +300,89 @@ AC_DEFUN([gl_INIT], m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) gl_COMMON gl_source_base='lib' + gl_source_base_prefix= AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([accept]) - fi + gl_CONDITIONAL([GL_COND_OBJ_ACCEPT], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([accept]) gl_FUNC_ACCEPT4 gl_SYS_SOCKET_MODULE_INDICATOR([accept4]) gl_FUNC_ALLOCA + gl_CONDITIONAL_HEADER([alloca.h]) + AC_PROG_MKDIR_P gl_ARPA_INET_H gl_ARPA_INET_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([bind]) - fi + gl_CONDITIONAL([GL_COND_OBJ_BIND], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([bind]) gl_BYTESWAP + gl_CONDITIONAL_HEADER([byteswap.h]) + AC_PROG_MKDIR_P gl_CANONICALIZE_LGPL - if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then - AC_LIBOBJ([canonicalize-lgpl]) - fi + gl_CONDITIONAL([GL_COND_OBJ_CANONICALIZE_LGPL], + [test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1]) gl_MODULE_INDICATOR([canonicalize-lgpl]) gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name]) gl_STDLIB_MODULE_INDICATOR([realpath]) gl_FUNC_CEIL - if test $REPLACE_CEIL = 1; then - AC_LIBOBJ([ceil]) - fi + gl_CONDITIONAL([GL_COND_OBJ_CEIL], [test $REPLACE_CEIL = 1]) gl_MATH_MODULE_INDICATOR([ceil]) gl_CLOCK_TIME gl_FUNC_CLOSE - if test $REPLACE_CLOSE = 1; then - AC_LIBOBJ([close]) - fi + gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1]) gl_UNISTD_MODULE_INDICATOR([close]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([connect]) - fi + gl_CONDITIONAL([GL_COND_OBJ_CONNECT], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([connect]) gl_FUNC_COPYSIGN - if test $HAVE_COPYSIGN = 0; then - AC_LIBOBJ([copysign]) - fi + gl_CONDITIONAL([GL_COND_OBJ_COPYSIGN], [test $HAVE_COPYSIGN = 0]) gl_MATH_MODULE_INDICATOR([copysign]) gl_DIRENT_H gl_DIRENT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_FUNC_DIRFD - if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no \ - || test $REPLACE_DIRFD = 1; then - AC_LIBOBJ([dirfd]) + gl_CONDITIONAL([GL_COND_OBJ_DIRFD], + [test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no || test $REPLACE_DIRFD = 1]) + AM_COND_IF([GL_COND_OBJ_DIRFD], [ gl_PREREQ_DIRFD - fi + ]) gl_DIRENT_MODULE_INDICATOR([dirfd]) gl_DOUBLE_SLASH_ROOT gl_FUNC_DUPLOCALE - if test $REPLACE_DUPLOCALE = 1; then - AC_LIBOBJ([duplocale]) + gl_CONDITIONAL([GL_COND_OBJ_DUPLOCALE], [test $REPLACE_DUPLOCALE = 1]) + AM_COND_IF([GL_COND_OBJ_DUPLOCALE], [ gl_PREREQ_DUPLOCALE - fi + ]) gl_LOCALE_MODULE_INDICATOR([duplocale]) gl_ENVIRON gl_UNISTD_MODULE_INDICATOR([environ]) gl_HEADER_ERRNO_H + gl_CONDITIONAL_HEADER([errno.h]) + AC_PROG_MKDIR_P AC_REQUIRE([gl_EXTERN_INLINE]) gl_FCNTL_H gl_FCNTL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P AC_C_FLEXIBLE_ARRAY_MEMBER gl_FLOAT_H - if test $REPLACE_FLOAT_LDBL = 1; then - AC_LIBOBJ([float]) - fi - if test $REPLACE_ITOLD = 1; then - AC_LIBOBJ([itold]) - fi + gl_CONDITIONAL_HEADER([float.h]) + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_FLOAT], [test $REPLACE_FLOAT_LDBL = 1]) + gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1]) gl_FUNC_FLOCK - if test $HAVE_FLOCK = 0; then - AC_LIBOBJ([flock]) + gl_CONDITIONAL([GL_COND_OBJ_FLOCK], [test $HAVE_FLOCK = 0]) + AM_COND_IF([GL_COND_OBJ_FLOCK], [ gl_PREREQ_FLOCK - fi + ]) gl_SYS_FILE_MODULE_INDICATOR([flock]) AC_REQUIRE([gl_FUNC_FLOOR]) - if test $REPLACE_FLOOR = 1; then - AC_LIBOBJ([floor]) - fi + gl_CONDITIONAL([GL_COND_OBJ_FLOOR], [test $REPLACE_FLOOR = 1]) gl_MATH_MODULE_INDICATOR([floor]) gl_FUNC_FREE - if test $REPLACE_FREE = 1; then - AC_LIBOBJ([free]) + gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1]) + AM_COND_IF([GL_COND_OBJ_FREE], [ gl_PREREQ_FREE - fi + ]) gl_STDLIB_MODULE_INDICATOR([free-posix]) AC_REQUIRE([gl_FUNC_FREXP]) if test $gl_func_frexp != yes; then @@ -384,51 +390,44 @@ AC_DEFUN([gl_INIT], fi gl_MATH_MODULE_INDICATOR([frexp]) gl_FUNC_FSTAT - if test $REPLACE_FSTAT = 1; then - AC_LIBOBJ([fstat]) + gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1]) + AM_COND_IF([GL_COND_OBJ_FSTAT], [ case "$host_os" in mingw*) AC_LIBOBJ([stat-w32]) ;; esac gl_PREREQ_FSTAT - fi + ]) gl_SYS_STAT_MODULE_INDICATOR([fstat]) gl_FUNC_FSYNC - if test $HAVE_FSYNC = 0; then - AC_LIBOBJ([fsync]) + gl_CONDITIONAL([GL_COND_OBJ_FSYNC], [test $HAVE_FSYNC = 0]) + AM_COND_IF([GL_COND_OBJ_FSYNC], [ gl_PREREQ_FSYNC - fi + ]) gl_UNISTD_MODULE_INDICATOR([fsync]) gl_FUNC gl_GETADDRINFO - if test $HAVE_GETADDRINFO = 0 || test $REPLACE_GETADDRINFO = 1; then - AC_LIBOBJ([getaddrinfo]) - fi - if test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1; then - AC_LIBOBJ([gai_strerror]) - fi + gl_CONDITIONAL([GL_COND_OBJ_GETADDRINFO], + [test $HAVE_GETADDRINFO = 0 || test $REPLACE_GETADDRINFO = 1]) + gl_CONDITIONAL([GL_COND_OBJ_GAI_STRERROR], + [test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1]) gl_NETDB_MODULE_INDICATOR([getaddrinfo]) gl_FUNC_GETLOGIN - if test $HAVE_GETLOGIN = 0; then - AC_LIBOBJ([getlogin]) - fi + gl_CONDITIONAL([GL_COND_OBJ_GETLOGIN], [test $HAVE_GETLOGIN = 0]) gl_UNISTD_MODULE_INDICATOR([getlogin]) AC_REQUIRE([gl_LIB_GETLOGIN]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([getpeername]) - fi + gl_CONDITIONAL([GL_COND_OBJ_GETPEERNAME], + [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([getpeername]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([getsockname]) - fi + gl_CONDITIONAL([GL_COND_OBJ_GETSOCKNAME], + [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([getsockname]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([getsockopt]) - fi + gl_CONDITIONAL([GL_COND_OBJ_GETSOCKOPT], + [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([getsockopt]) # Autoconf 2.61a.99 and earlier don't support linking a file only # in VPATH builds. But since GNUmakefile is for maintainer use @@ -446,38 +445,36 @@ AC_DEFUN([gl_INIT], [gl_ICONV_MODULE_INDICATOR([iconv])]) gl_ICONV_H gl_ICONV_H_REQUIRE_DEFAULTS + gl_CONDITIONAL_HEADER([iconv.h]) + AC_PROG_MKDIR_P gl_FUNC_ICONV_OPEN - if test $REPLACE_ICONV_OPEN = 1; then - AC_LIBOBJ([iconv_open]) - fi - if test $REPLACE_ICONV = 1; then - AC_LIBOBJ([iconv]) - AC_LIBOBJ([iconv_close]) - fi + dnl Because of gl_REPLACE_ICONV_H: + gl_CONDITIONAL_HEADER([iconv.h]) + gl_CONDITIONAL([GL_COND_OBJ_ICONV_OPEN], [test $REPLACE_ICONV_OPEN = 1]) + gl_CONDITIONAL([GL_COND_OBJ_ICONV], [test $REPLACE_ICONV = 1]) gl_FUNC_ICONV_OPEN_UTF gl_FUNC_INET_NTOP - if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then - AC_LIBOBJ([inet_ntop]) + gl_CONDITIONAL([GL_COND_OBJ_INET_NTOP], + [test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1]) + AM_COND_IF([GL_COND_OBJ_INET_NTOP], [ gl_PREREQ_INET_NTOP - fi + ]) gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) gl_FUNC_INET_PTON - if test $HAVE_INET_PTON = 0 || test $REPLACE_INET_PTON = 1; then - AC_LIBOBJ([inet_pton]) + gl_CONDITIONAL([GL_COND_OBJ_INET_PTON], + [test $HAVE_INET_PTON = 0 || test $REPLACE_INET_PTON = 1]) + AM_COND_IF([GL_COND_OBJ_INET_PTON], [ gl_PREREQ_INET_PTON - fi + ]) gl_ARPA_INET_MODULE_INDICATOR([inet_pton]) gl_INTTYPES_INCOMPLETE gl_INTTYPES_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_ISFINITE - if test $REPLACE_ISFINITE = 1; then - AC_LIBOBJ([isfinite]) - fi + gl_CONDITIONAL([GL_COND_OBJ_ISFINITE], [test $REPLACE_ISFINITE = 1]) gl_MATH_MODULE_INDICATOR([isfinite]) gl_ISINF - if test $REPLACE_ISINF = 1; then - AC_LIBOBJ([isinf]) - fi + gl_CONDITIONAL([GL_COND_OBJ_ISINF], [test $REPLACE_ISINF = 1]) gl_MATH_MODULE_INDICATOR([isinf]) gl_ISNAN gl_MATH_MODULE_INDICATOR([isnan]) @@ -510,21 +507,22 @@ AC_DEFUN([gl_INIT], gl_MATH_MODULE_INDICATOR([isnanl]) gl_LANGINFO_H gl_LANGINFO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P AC_REQUIRE([gl_LARGEFILE]) gl_FUNC_LDEXP gl_LD_VERSION_SCRIPT gl_VISIBILITY + gl___INLINE gl_LIBUNISTRING gl_LIMITS_H + gl_CONDITIONAL_HEADER([limits.h]) + AC_PROG_MKDIR_P gl_FUNC_LINK - if test $HAVE_LINK = 0 || test $REPLACE_LINK = 1; then - AC_LIBOBJ([link]) - fi + gl_CONDITIONAL([GL_COND_OBJ_LINK], + [test $HAVE_LINK = 0 || test $REPLACE_LINK = 1]) gl_UNISTD_MODULE_INDICATOR([link]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([listen]) - fi + gl_CONDITIONAL([GL_COND_OBJ_LISTEN], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([listen]) gl_LOCALCHARSET dnl For backward compatibility. Some packages still use this. @@ -532,173 +530,159 @@ AC_DEFUN([gl_INIT], AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) gl_LOCALE_H gl_LOCALE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_FUNC_LOG1P - if test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1; then - AC_LIBOBJ([log1p]) - fi + gl_CONDITIONAL([GL_COND_OBJ_LOG1P], + [test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1]) gl_MATH_MODULE_INDICATOR([log1p]) gl_FUNC_LSTAT - if test $REPLACE_LSTAT = 1; then - AC_LIBOBJ([lstat]) + gl_CONDITIONAL([GL_COND_OBJ_LSTAT], [test $REPLACE_LSTAT = 1]) + AM_COND_IF([GL_COND_OBJ_LSTAT], [ gl_PREREQ_LSTAT - fi + ]) gl_SYS_STAT_MODULE_INDICATOR([lstat]) AC_CONFIG_COMMANDS_PRE([m4_ifdef([AH_HEADER], [AC_SUBST([CONFIG_INCLUDE], m4_defn([AH_HEADER]))])]) AC_REQUIRE([AC_PROG_SED]) AC_REQUIRE([AC_PROG_GREP]) gl_FUNC_MALLOC_GNU - if test $REPLACE_MALLOC = 1; then + if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then AC_LIBOBJ([malloc]) fi + gl_STDLIB_MODULE_INDICATOR([malloc-gnu]) AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) - if test $REPLACE_MALLOC = 1; then + if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then AC_LIBOBJ([malloc]) fi gl_STDLIB_MODULE_INDICATOR([malloc-posix]) gl_MALLOCA gl_MATH_H gl_MATH_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_MINMAX gl_FUNC_MKDIR - if test $REPLACE_MKDIR = 1; then - AC_LIBOBJ([mkdir]) - fi + gl_CONDITIONAL([GL_COND_OBJ_MKDIR], [test $REPLACE_MKDIR = 1]) gl_SYS_STAT_MODULE_INDICATOR([mkdir]) gl_FUNC_MKOSTEMP - if test $HAVE_MKOSTEMP = 0; then - AC_LIBOBJ([mkostemp]) + gl_CONDITIONAL([GL_COND_OBJ_MKOSTEMP], [test $HAVE_MKOSTEMP = 0]) + AM_COND_IF([GL_COND_OBJ_MKOSTEMP], [ gl_PREREQ_MKOSTEMP - fi + ]) gl_MODULE_INDICATOR([mkostemp]) gl_STDLIB_MODULE_INDICATOR([mkostemp]) AC_REQUIRE([gl_MSVC_INVAL]) - if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then - AC_LIBOBJ([msvc-inval]) - fi + gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL], + [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) AC_REQUIRE([gl_MSVC_NOTHROW]) - if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then - AC_LIBOBJ([msvc-nothrow]) - fi + gl_CONDITIONAL([GL_COND_OBJ_MSVC_NOTHROW], + [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) gl_MODULE_INDICATOR([msvc-nothrow]) gl_MULTIARCH gl_NETDB_H gl_NETDB_H_REQUIRE_DEFAULTS - gl_HEADER_NETINET_IN AC_PROG_MKDIR_P gl_FUNC_NL_LANGINFO - if test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1; then - AC_LIBOBJ([nl_langinfo]) - fi + gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO], + [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1]) + gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO_LOCK], + [test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0]) if test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0; then - AC_LIBOBJ([nl_langinfo-lock]) gl_PREREQ_NL_LANGINFO_LOCK fi gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) gl_NPROC gl_FUNC_GNU_STRFTIME gl_FUNC_OPEN - if test $REPLACE_OPEN = 1; then - AC_LIBOBJ([open]) + gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1]) + AM_COND_IF([GL_COND_OBJ_OPEN], [ gl_PREREQ_OPEN - fi + ]) gl_FCNTL_MODULE_INDICATOR([open]) gl_FUNC_PIPE - if test $HAVE_PIPE = 0; then - AC_LIBOBJ([pipe]) - fi + gl_CONDITIONAL([GL_COND_OBJ_PIPE], [test $HAVE_PIPE = 0]) gl_UNISTD_MODULE_INDICATOR([pipe]) gl_FUNC_PIPE2 gl_UNISTD_MODULE_INDICATOR([pipe2]) gl_FUNC_POLL - if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then - AC_LIBOBJ([poll]) + gl_CONDITIONAL([GL_COND_OBJ_POLL], + [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]) + AM_COND_IF([GL_COND_OBJ_POLL], [ gl_PREREQ_POLL - fi + ]) gl_POLL_MODULE_INDICATOR([poll]) gl_POLL_H gl_POLL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_POSIX_SPAWN + gl_CONDITIONAL([GL_COND_OBJ_SPAWNP], + [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1]) + gl_SPAWN_MODULE_INDICATOR([posix_spawnp]) gl_FUNC_PUTENV - if test $REPLACE_PUTENV = 1; then - AC_LIBOBJ([putenv]) + gl_CONDITIONAL([GL_COND_OBJ_PUTENV], [test $REPLACE_PUTENV = 1]) + AM_COND_IF([GL_COND_OBJ_PUTENV], [ gl_PREREQ_PUTENV - fi + ]) gl_STDLIB_MODULE_INDICATOR([putenv]) gl_FUNC_READ - if test $REPLACE_READ = 1; then - AC_LIBOBJ([read]) + gl_CONDITIONAL([GL_COND_OBJ_READ], [test $REPLACE_READ = 1]) + AM_COND_IF([GL_COND_OBJ_READ], [ gl_PREREQ_READ - fi + ]) gl_UNISTD_MODULE_INDICATOR([read]) gl_FUNC_READLINK - if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then - AC_LIBOBJ([readlink]) + gl_CONDITIONAL([GL_COND_OBJ_READLINK], + [test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1]) + AM_COND_IF([GL_COND_OBJ_READLINK], [ gl_PREREQ_READLINK - fi + ]) gl_UNISTD_MODULE_INDICATOR([readlink]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([recv]) - fi + gl_CONDITIONAL([GL_COND_OBJ_RECV], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([recv]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([recvfrom]) - fi + gl_CONDITIONAL([GL_COND_OBJ_RECVFROM], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([recvfrom]) gl_REGEX - if test $ac_use_included_regex = yes; then - AC_LIBOBJ([regex]) + gl_CONDITIONAL([GL_COND_OBJ_REGEX], [test $ac_use_included_regex = yes]) + AM_COND_IF([GL_COND_OBJ_REGEX], [ gl_PREREQ_REGEX - fi + ]) gl_FUNC_RENAME - if test $REPLACE_RENAME = 1; then - AC_LIBOBJ([rename]) - fi + gl_CONDITIONAL([GL_COND_OBJ_RENAME], [test $REPLACE_RENAME = 1]) gl_STDIO_MODULE_INDICATOR([rename]) gl_FUNC_RMDIR - if test $REPLACE_RMDIR = 1; then - AC_LIBOBJ([rmdir]) - fi + gl_CONDITIONAL([GL_COND_OBJ_RMDIR], [test $REPLACE_RMDIR = 1]) gl_UNISTD_MODULE_INDICATOR([rmdir]) gl_PREREQ_SAFE_READ gl_PREREQ_SAFE_WRITE + gl_SCHED_H + gl_SCHED_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_FUNC_SELECT - if test $REPLACE_SELECT = 1; then - AC_LIBOBJ([select]) - fi + gl_CONDITIONAL([GL_COND_OBJ_SELECT], [test $REPLACE_SELECT = 1]) gl_SYS_SELECT_MODULE_INDICATOR([select]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([send]) - fi + gl_CONDITIONAL([GL_COND_OBJ_SEND], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([send]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([sendto]) - fi + gl_CONDITIONAL([GL_COND_OBJ_SENDTO], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([sendto]) gl_FUNC_SETENV - if test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1; then - AC_LIBOBJ([setenv]) - fi + gl_CONDITIONAL([GL_COND_OBJ_SETENV], + [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1]) gl_STDLIB_MODULE_INDICATOR([setenv]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([setsockopt]) - fi + gl_CONDITIONAL([GL_COND_OBJ_SETSOCKOPT], + [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([setsockopt]) AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([shutdown]) - fi + gl_CONDITIONAL([GL_COND_OBJ_SHUTDOWN], [test "$ac_cv_header_winsock2_h" = yes]) gl_SYS_SOCKET_MODULE_INDICATOR([shutdown]) gl_SIGNAL_H gl_SIGNAL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P AC_REQUIRE([gl_SYS_SOCKET_H]) - if test "$ac_cv_header_winsock2_h" = yes; then - AC_LIBOBJ([socket]) - fi + gl_CONDITIONAL([GL_COND_OBJ_SOCKET], [test "$ac_cv_header_winsock2_h" = yes]) # When this module is used, sockets may actually occur as file descriptors, # hence it is worth warning if the modules 'close' and 'ioctl' are not used. m4_ifdef([gl_UNISTD_H_DEFAULTS], [gl_UNISTD_H_REQUIRE_DEFAULTS]) @@ -711,16 +695,40 @@ AC_DEFUN([gl_INIT], gl_SYS_SOCKET_MODULE_INDICATOR([socket]) AC_REQUIRE([gl_SOCKETLIB]) gl_TYPE_SOCKLEN_T + gl_SPAWN_H + gl_SPAWN_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gt_TYPE_SSIZE_T gl_STAT_TIME gl_STAT_BIRTHTIME gl_STDALIGN_H - AM_STDBOOL_H + gl_CONDITIONAL_HEADER([stdalign.h]) + AC_PROG_MKDIR_P + gl_STDBOOL_H + gl_CONDITIONAL_HEADER([stdbool.h]) + AC_PROG_MKDIR_P + AC_CHECK_HEADERS_ONCE([stdckdint.h]) + if test $ac_cv_header_stdckdint_h = yes; then + GL_GENERATE_STDCKDINT_H=false + else + GL_GENERATE_STDCKDINT_H=true + fi + gl_CONDITIONAL_HEADER([stdckdint.h]) + AC_PROG_MKDIR_P gl_STDDEF_H gl_STDDEF_H_REQUIRE_DEFAULTS + gl_CONDITIONAL_HEADER([stddef.h]) + AC_PROG_MKDIR_P gl_STDINT_H + gl_CONDITIONAL_HEADER([stdint.h]) + dnl Because of gl_REPLACE_LIMITS_H: + gl_CONDITIONAL_HEADER([limits.h]) + AC_PROG_MKDIR_P gl_STDIO_H gl_STDIO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_STDIO_READ], [test $REPLACE_STDIO_READ_FUNCS = 1]) + gl_CONDITIONAL([GL_COND_OBJ_STDIO_WRITE], [test $REPLACE_STDIO_WRITE_FUNCS = 1]) dnl No need to create extra modules for these functions. Everyone who uses dnl likely needs them. gl_STDIO_MODULE_INDICATOR([fscanf]) @@ -746,12 +754,14 @@ AC_DEFUN([gl_INIT], gl_STDIO_MODULE_INDICATOR([fwrite]) gl_STDLIB_H gl_STDLIB_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P if test $gl_cond_libtool = false; then gl_ltlibdeps="$gl_ltlibdeps $LTLIBICONV" gl_libdeps="$gl_libdeps $LIBICONV" fi gl_STRING_H gl_STRING_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_SYS_FILE_H gl_SYS_FILE_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P @@ -778,44 +788,46 @@ AC_DEFUN([gl_INIT], AC_PROG_MKDIR_P gl_TIME_H gl_TIME_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_TIME_RZ - if test $HAVE_TIMEZONE_T = 0; then - AC_LIBOBJ([time_rz]) - fi + gl_CONDITIONAL([GL_COND_OBJ_TIME_RZ], [test $HAVE_TIMEZONE_T = 0]) gl_TIME_MODULE_INDICATOR([time_rz]) gl_FUNC_TIMES - if test $HAVE_TIMES = 0; then - AC_LIBOBJ([times]) - fi + gl_CONDITIONAL([GL_COND_OBJ_TIMES], [test $HAVE_TIMES = 0]) gl_SYS_TIMES_MODULE_INDICATOR([times]) gl_FUNC_TRUNC - if test $HAVE_DECL_TRUNC = 0 || test $REPLACE_TRUNC = 1; then - AC_LIBOBJ([trunc]) - fi + gl_CONDITIONAL([GL_COND_OBJ_TRUNC], + [test $HAVE_DECL_TRUNC = 0 || test $REPLACE_TRUNC = 1]) gl_MATH_MODULE_INDICATOR([trunc]) gl_UNISTD_H gl_UNISTD_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_C_VARARRAYS gl_FUNC_VSNPRINTF gl_STDIO_MODULE_INDICATOR([vsnprintf]) gl_WCHAR_H gl_WCHAR_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_FUNC_WRITE - if test $REPLACE_WRITE = 1; then - AC_LIBOBJ([write]) + gl_CONDITIONAL([GL_COND_OBJ_WRITE], [test $REPLACE_WRITE = 1]) + AM_COND_IF([GL_COND_OBJ_WRITE], [ gl_PREREQ_WRITE - fi + ]) gl_UNISTD_MODULE_INDICATOR([write]) + gl_gnulib_enabled_access=false gl_gnulib_enabled_alloca=false gl_gnulib_enabled_assure=false gl_gnulib_enabled_btowc=false gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547=false gl_gnulib_enabled_chdir=false gl_gnulib_enabled_cloexec=false + gl_gnulib_enabled_6da965dc4d3aa4f87d68116dce96f1a5=false gl_gnulib_enabled_dup2=false gl_gnulib_enabled_dynarray=false gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c=false gl_gnulib_enabled_fcntl=false gl_gnulib_enabled_43fe87a341d9b4b93c47c3ad819a5239=false + gl_gnulib_enabled_7be38c8cf2027003f573b80556d26ff2=false gl_gnulib_enabled_getdtablesize=false gl_gnulib_enabled_getrandom=false gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false @@ -824,7 +836,6 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_b1df7117b479d2da59d76deba468ee21=false gl_gnulib_enabled_3f0e593033d1fc2c127581960f641b66=false gl_gnulib_enabled_dbdf22868a5367f28bf18e0013ac6f8f=false - gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467=false gl_gnulib_enabled_localeconv=false gl_gnulib_enabled_log=false gl_gnulib_enabled_mbrtowc=false @@ -834,7 +845,9 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_mempcpy=false gl_gnulib_enabled_mktime=false gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false + gl_gnulib_enabled_netinet_in=false gl_gnulib_enabled_pathmax=false + gl_gnulib_enabled_332607f759618fb73dfc3076748afea7=false gl_gnulib_enabled_raise=false gl_gnulib_enabled_rawmemchr=false gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=false @@ -843,11 +856,14 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_scratch_buffer=false gl_gnulib_enabled_servent=false gl_gnulib_enabled_e7e881d32ca02f1c997b13c737c64bbd=false + gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70=false gl_gnulib_enabled_signbit=false gl_gnulib_enabled_size_max=false gl_gnulib_enabled_snprintf=false gl_gnulib_enabled_sockets=false gl_gnulib_enabled_stat=false + gl_gnulib_enabled_stpcpy=false + gl_gnulib_enabled_strchrnul=false gl_gnulib_enabled_f9850631dca91859e9cddac9359921c0=false gl_gnulib_enabled_streq=false gl_gnulib_enabled_sys_random=false @@ -859,7 +875,18 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_vasnprintf=false gl_gnulib_enabled_wcrtomb=false gl_gnulib_enabled_3dcce957eadc896e63ab5f137947b410=false + gl_gnulib_enabled_fd43d02c899a251eacc999baf40b238e=false gl_gnulib_enabled_xsize=false + func_gl_gnulib_m4code_access () + { + if ! $gl_gnulib_enabled_access; then + gl_FUNC_ACCESS + gl_CONDITIONAL([GL_COND_OBJ_ACCESS], [test $REPLACE_ACCESS = 1]) + gl_UNISTD_MODULE_INDICATOR([access]) + gl_gnulib_enabled_access=true + func_gl_gnulib_m4code_fcntl + fi + } func_gl_gnulib_m4code_alloca () { if ! $gl_gnulib_enabled_alloca; then @@ -880,10 +907,11 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_btowc; then gl_FUNC_BTOWC - if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then - AC_LIBOBJ([btowc]) + gl_CONDITIONAL([GL_COND_OBJ_BTOWC], + [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_BTOWC], [ gl_PREREQ_BTOWC - fi + ]) gl_WCHAR_MODULE_INDICATOR([btowc]) gl_gnulib_enabled_btowc=true if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then @@ -914,14 +942,21 @@ AC_SUBST([LTALLOCA]) func_gl_gnulib_m4code_fcntl fi } + func_gl_gnulib_m4code_6da965dc4d3aa4f87d68116dce96f1a5 () + { + if ! $gl_gnulib_enabled_6da965dc4d3aa4f87d68116dce96f1a5; then + gl_gnulib_enabled_6da965dc4d3aa4f87d68116dce96f1a5=true + func_gl_gnulib_m4code_stpcpy + fi + } func_gl_gnulib_m4code_dup2 () { if ! $gl_gnulib_enabled_dup2; then gl_FUNC_DUP2 - if test $REPLACE_DUP2 = 1; then - AC_LIBOBJ([dup2]) + gl_CONDITIONAL([GL_COND_OBJ_DUP2], [test $REPLACE_DUP2 = 1]) + AM_COND_IF([GL_COND_OBJ_DUP2], [ gl_PREREQ_DUP2 - fi + ]) gl_UNISTD_MODULE_INDICATOR([dup2]) gl_gnulib_enabled_dup2=true fi @@ -932,7 +967,6 @@ AC_SUBST([LTALLOCA]) AC_PROG_MKDIR_P gl_gnulib_enabled_dynarray=true func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547 - func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 fi } func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c () @@ -945,9 +979,8 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_fcntl; then gl_FUNC_FCNTL - if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then - AC_LIBOBJ([fcntl]) - fi + gl_CONDITIONAL([GL_COND_OBJ_FCNTL], + [test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1]) gl_FCNTL_MODULE_INDICATOR([fcntl]) gl_gnulib_enabled_fcntl=true if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then @@ -964,14 +997,26 @@ AC_SUBST([LTALLOCA]) gl_gnulib_enabled_43fe87a341d9b4b93c47c3ad819a5239=true fi } + func_gl_gnulib_m4code_7be38c8cf2027003f573b80556d26ff2 () + { + if ! $gl_gnulib_enabled_7be38c8cf2027003f573b80556d26ff2; then + gl_FINDPROG_IN + gl_gnulib_enabled_7be38c8cf2027003f573b80556d26ff2=true + func_gl_gnulib_m4code_access + func_gl_gnulib_m4code_6da965dc4d3aa4f87d68116dce96f1a5 + func_gl_gnulib_m4code_stat + func_gl_gnulib_m4code_f9850631dca91859e9cddac9359921c0 + fi + } func_gl_gnulib_m4code_getdtablesize () { if ! $gl_gnulib_enabled_getdtablesize; then gl_FUNC_GETDTABLESIZE - if test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1; then - AC_LIBOBJ([getdtablesize]) + gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE], + [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1]) + AM_COND_IF([GL_COND_OBJ_GETDTABLESIZE], [ gl_PREREQ_GETDTABLESIZE - fi + ]) gl_UNISTD_MODULE_INDICATOR([getdtablesize]) gl_gnulib_enabled_getdtablesize=true fi @@ -981,9 +1026,8 @@ AC_SUBST([LTALLOCA]) if ! $gl_gnulib_enabled_getrandom; then AC_REQUIRE([AC_CANONICAL_HOST]) gl_FUNC_GETRANDOM - if test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1; then - AC_LIBOBJ([getrandom]) - fi + gl_CONDITIONAL([GL_COND_OBJ_GETRANDOM], + [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1]) gl_SYS_RANDOM_MODULE_INDICATOR([getrandom]) gl_gnulib_enabled_getrandom=true func_gl_gnulib_m4code_sys_random @@ -1047,21 +1091,14 @@ AC_SUBST([LTALLOCA]) gl_gnulib_enabled_dbdf22868a5367f28bf18e0013ac6f8f=true fi } - func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 () - { - if ! $gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467; then - gl___INLINE - gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467=true - fi - } func_gl_gnulib_m4code_localeconv () { if ! $gl_gnulib_enabled_localeconv; then gl_FUNC_LOCALECONV - if test $REPLACE_LOCALECONV = 1; then - AC_LIBOBJ([localeconv]) + gl_CONDITIONAL([GL_COND_OBJ_LOCALECONV], [test $REPLACE_LOCALECONV = 1]) + AM_COND_IF([GL_COND_OBJ_LOCALECONV], [ gl_PREREQ_LOCALECONV - fi + ]) gl_LOCALE_MODULE_INDICATOR([localeconv]) gl_gnulib_enabled_localeconv=true fi @@ -1070,9 +1107,7 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_log; then AC_REQUIRE([gl_FUNC_LOG]) - if test $REPLACE_LOG = 1; then - AC_LIBOBJ([log]) - fi + gl_CONDITIONAL([GL_COND_OBJ_LOG], [test $REPLACE_LOG = 1]) gl_MATH_MODULE_INDICATOR([log]) gl_gnulib_enabled_log=true fi @@ -1081,15 +1116,16 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_mbrtowc; then gl_FUNC_MBRTOWC - if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then - AC_LIBOBJ([mbrtowc]) + gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC], + [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_MBRTOWC], [ if test $REPLACE_MBSTATE_T = 1; then AC_LIBOBJ([lc-charset-dispatch]) AC_LIBOBJ([mbtowc-lock]) gl_PREREQ_MBTOWC_LOCK fi gl_PREREQ_MBRTOWC - fi + ]) gl_WCHAR_MODULE_INDICATOR([mbrtowc]) gl_gnulib_enabled_mbrtowc=true if { test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; } && test $REPLACE_MBSTATE_T = 0; then @@ -1107,10 +1143,11 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_mbsinit; then gl_FUNC_MBSINIT - if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then - AC_LIBOBJ([mbsinit]) + gl_CONDITIONAL([GL_COND_OBJ_MBSINIT], + [test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1]) + AM_COND_IF([GL_COND_OBJ_MBSINIT], [ gl_PREREQ_MBSINIT - fi + ]) gl_WCHAR_MODULE_INDICATOR([mbsinit]) gl_gnulib_enabled_mbsinit=true if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then @@ -1122,10 +1159,11 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_mbtowc; then gl_FUNC_MBTOWC - if test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1; then - AC_LIBOBJ([mbtowc]) + gl_CONDITIONAL([GL_COND_OBJ_MBTOWC], + [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_MBTOWC], [ gl_PREREQ_MBTOWC - fi + ]) gl_STDLIB_MODULE_INDICATOR([mbtowc]) gl_gnulib_enabled_mbtowc=true if test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1; then @@ -1137,10 +1175,10 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_memchr; then gl_FUNC_MEMCHR - if test $REPLACE_MEMCHR = 1; then - AC_LIBOBJ([memchr]) + gl_CONDITIONAL([GL_COND_OBJ_MEMCHR], [test $REPLACE_MEMCHR = 1]) + AM_COND_IF([GL_COND_OBJ_MEMCHR], [ gl_PREREQ_MEMCHR - fi + ]) gl_STRING_MODULE_INDICATOR([memchr]) gl_gnulib_enabled_memchr=true fi @@ -1149,10 +1187,10 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_mempcpy; then gl_FUNC_MEMPCPY - if test $HAVE_MEMPCPY = 0; then - AC_LIBOBJ([mempcpy]) + gl_CONDITIONAL([GL_COND_OBJ_MEMPCPY], [test $HAVE_MEMPCPY = 0]) + AM_COND_IF([GL_COND_OBJ_MEMPCPY], [ gl_PREREQ_MEMPCPY - fi + ]) gl_STRING_MODULE_INDICATOR([mempcpy]) gl_gnulib_enabled_mempcpy=true fi @@ -1167,9 +1205,6 @@ AC_SUBST([LTALLOCA]) fi gl_TIME_MODULE_INDICATOR([mktime]) gl_gnulib_enabled_mktime=true - if test $REPLACE_MKTIME = 1; then - func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 - fi if test $REPLACE_MKTIME = 1; then func_gl_gnulib_m4code_time_r fi @@ -1187,6 +1222,15 @@ AC_SUBST([LTALLOCA]) func_gl_gnulib_m4code_mktime fi } + func_gl_gnulib_m4code_netinet_in () + { + if ! $gl_gnulib_enabled_netinet_in; then + gl_HEADER_NETINET_IN + gl_CONDITIONAL_HEADER([netinet/in.h]) + AC_PROG_MKDIR_P + gl_gnulib_enabled_netinet_in=true + fi + } func_gl_gnulib_m4code_pathmax () { if ! $gl_gnulib_enabled_pathmax; then @@ -1194,14 +1238,39 @@ AC_SUBST([LTALLOCA]) gl_gnulib_enabled_pathmax=true fi } + func_gl_gnulib_m4code_332607f759618fb73dfc3076748afea7 () + { + if ! $gl_gnulib_enabled_332607f759618fb73dfc3076748afea7; then + gl_POSIX_SPAWN + gl_CONDITIONAL([GL_COND_OBJ_SPAWNI], + [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1]) + AM_COND_IF([GL_COND_OBJ_SPAWNI], [ + gl_PREREQ_POSIX_SPAWN_INTERNAL + ]) + gl_gnulib_enabled_332607f759618fb73dfc3076748afea7=true + if test $HAVE_POSIX_SPAWN = 0; then + func_gl_gnulib_m4code_6da965dc4d3aa4f87d68116dce96f1a5 + fi + func_gl_gnulib_m4code_dup2 + if test $HAVE_POSIX_SPAWN = 0; then + func_gl_gnulib_m4code_7be38c8cf2027003f573b80556d26ff2 + fi + func_gl_gnulib_m4code_cdeb0f2aaf9d280baa6526bfa1b07f70 + func_gl_gnulib_m4code_strchrnul + if test $HAVE_POSIX_SPAWN = 0; then + func_gl_gnulib_m4code_fd43d02c899a251eacc999baf40b238e + fi + fi + } func_gl_gnulib_m4code_raise () { if ! $gl_gnulib_enabled_raise; then gl_FUNC_RAISE - if test $HAVE_RAISE = 0 || test $REPLACE_RAISE = 1; then - AC_LIBOBJ([raise]) + gl_CONDITIONAL([GL_COND_OBJ_RAISE], + [test $HAVE_RAISE = 0 || test $REPLACE_RAISE = 1]) + AM_COND_IF([GL_COND_OBJ_RAISE], [ gl_PREREQ_RAISE - fi + ]) gl_SIGNAL_MODULE_INDICATOR([raise]) gl_gnulib_enabled_raise=true fi @@ -1210,10 +1279,10 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_rawmemchr; then gl_FUNC_RAWMEMCHR - if test $HAVE_RAWMEMCHR = 0; then - AC_LIBOBJ([rawmemchr]) + gl_CONDITIONAL([GL_COND_OBJ_RAWMEMCHR], [test $HAVE_RAWMEMCHR = 0]) + AM_COND_IF([GL_COND_OBJ_RAWMEMCHR], [ gl_PREREQ_RAWMEMCHR - fi + ]) gl_STRING_MODULE_INDICATOR([rawmemchr]) gl_gnulib_enabled_rawmemchr=true fi @@ -1222,7 +1291,7 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4; then gl_FUNC_REALLOC_POSIX - if test $REPLACE_REALLOC = 1; then + if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then AC_LIBOBJ([realloc]) fi gl_STDLIB_MODULE_INDICATOR([realloc-posix]) @@ -1233,9 +1302,8 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_round; then gl_FUNC_ROUND - if test $HAVE_ROUND = 0 || test $REPLACE_ROUND = 1; then - AC_LIBOBJ([round]) - fi + gl_CONDITIONAL([GL_COND_OBJ_ROUND], + [test $HAVE_ROUND = 0 || test $REPLACE_ROUND = 1]) gl_MATH_MODULE_INDICATOR([round]) gl_gnulib_enabled_round=true fi @@ -1252,7 +1320,6 @@ AC_SUBST([LTALLOCA]) AC_PROG_MKDIR_P gl_gnulib_enabled_scratch_buffer=true func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547 - func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 fi } @@ -1267,23 +1334,27 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_e7e881d32ca02f1c997b13c737c64bbd; then gl_FUNC_SETLOCALE_NULL - if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then - AC_LIBOBJ([setlocale-lock]) + gl_CONDITIONAL([GL_COND_OBJ_SETLOCALE_LOCK], + [test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0]) + AM_COND_IF([GL_COND_OBJ_SETLOCALE_LOCK], [ gl_PREREQ_SETLOCALE_LOCK - fi + ]) gl_LOCALE_MODULE_INDICATOR([setlocale_null]) gl_gnulib_enabled_e7e881d32ca02f1c997b13c737c64bbd=true fi } + func_gl_gnulib_m4code_cdeb0f2aaf9d280baa6526bfa1b07f70 () + { + if ! $gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70; then + gl_SH_FILENAME + gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70=true + fi + } func_gl_gnulib_m4code_signbit () { if ! $gl_gnulib_enabled_signbit; then gl_SIGNBIT - if test $REPLACE_SIGNBIT = 1; then - AC_LIBOBJ([signbitf]) - AC_LIBOBJ([signbitd]) - AC_LIBOBJ([signbitl]) - fi + gl_CONDITIONAL([GL_COND_OBJ_SIGNBIT3], [test $REPLACE_SIGNBIT = 1]) gl_MATH_MODULE_INDICATOR([signbit]) gl_gnulib_enabled_signbit=true if test $REPLACE_SIGNBIT = 1; then @@ -1328,15 +1399,15 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_stat; then gl_FUNC_STAT - if test $REPLACE_STAT = 1; then - AC_LIBOBJ([stat]) + gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1]) + AM_COND_IF([GL_COND_OBJ_STAT], [ case "$host_os" in mingw*) AC_LIBOBJ([stat-w32]) ;; esac gl_PREREQ_STAT - fi + ]) gl_SYS_STAT_MODULE_INDICATOR([stat]) gl_gnulib_enabled_stat=true if test $REPLACE_STAT = 1; then @@ -1344,14 +1415,42 @@ AC_SUBST([LTALLOCA]) fi fi } + func_gl_gnulib_m4code_stpcpy () + { + if ! $gl_gnulib_enabled_stpcpy; then + gl_FUNC_STPCPY + gl_CONDITIONAL([GL_COND_OBJ_STPCPY], [test $HAVE_STPCPY = 0]) + AM_COND_IF([GL_COND_OBJ_STPCPY], [ + gl_PREREQ_STPCPY + ]) + gl_STRING_MODULE_INDICATOR([stpcpy]) + gl_gnulib_enabled_stpcpy=true + fi + } + func_gl_gnulib_m4code_strchrnul () + { + if ! $gl_gnulib_enabled_strchrnul; then + gl_FUNC_STRCHRNUL + gl_CONDITIONAL([GL_COND_OBJ_STRCHRNUL], + [test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1]) + AM_COND_IF([GL_COND_OBJ_STRCHRNUL], [ + gl_PREREQ_STRCHRNUL + ]) + gl_STRING_MODULE_INDICATOR([strchrnul]) + gl_gnulib_enabled_strchrnul=true + if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then + func_gl_gnulib_m4code_rawmemchr + fi + fi + } func_gl_gnulib_m4code_f9850631dca91859e9cddac9359921c0 () { if ! $gl_gnulib_enabled_f9850631dca91859e9cddac9359921c0; then gl_FUNC_STRDUP_POSIX - if test $REPLACE_STRDUP = 1; then - AC_LIBOBJ([strdup]) + gl_CONDITIONAL([GL_COND_OBJ_STRDUP], [test $REPLACE_STRDUP = 1]) + AM_COND_IF([GL_COND_OBJ_STRDUP], [ gl_PREREQ_STRDUP - fi + ]) gl_STRING_MODULE_INDICATOR([strdup]) gl_gnulib_enabled_f9850631dca91859e9cddac9359921c0=true fi @@ -1378,17 +1477,17 @@ AC_SUBST([LTALLOCA]) gl_MODULE_INDICATOR([tempname]) gl_gnulib_enabled_tempname=true func_gl_gnulib_m4code_getrandom - func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 fi } func_gl_gnulib_m4code_time_r () { if ! $gl_gnulib_enabled_time_r; then gl_TIME_R - if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then - AC_LIBOBJ([time_r]) + gl_CONDITIONAL([GL_COND_OBJ_TIME_R], + [test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1]) + AM_COND_IF([GL_COND_OBJ_TIME_R], [ gl_PREREQ_TIME_R - fi + ]) gl_TIME_MODULE_INDICATOR([time_r]) gl_gnulib_enabled_time_r=true fi @@ -1397,10 +1496,11 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_timegm; then gl_FUNC_TIMEGM - if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then - AC_LIBOBJ([timegm]) + gl_CONDITIONAL([GL_COND_OBJ_TIMEGM], + [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1]) + AM_COND_IF([GL_COND_OBJ_TIMEGM], [ gl_PREREQ_TIMEGM - fi + ]) gl_TIME_MODULE_INDICATOR([timegm]) gl_gnulib_enabled_timegm=true if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then @@ -1415,9 +1515,7 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_tzset; then gl_FUNC_TZSET - if test $REPLACE_TZSET = 1; then - AC_LIBOBJ([tzset]) - fi + gl_CONDITIONAL([GL_COND_OBJ_TZSET], [test $REPLACE_TZSET = 1]) gl_TIME_MODULE_INDICATOR([tzset]) gl_gnulib_enabled_tzset=true fi @@ -1426,10 +1524,11 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_unsetenv; then gl_FUNC_UNSETENV - if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then - AC_LIBOBJ([unsetenv]) + gl_CONDITIONAL([GL_COND_OBJ_UNSETENV], + [test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1]) + AM_COND_IF([GL_COND_OBJ_UNSETENV], [ gl_PREREQ_UNSETENV - fi + ]) gl_STDLIB_MODULE_INDICATOR([unsetenv]) gl_gnulib_enabled_unsetenv=true fi @@ -1448,10 +1547,11 @@ AC_SUBST([LTALLOCA]) { if ! $gl_gnulib_enabled_wcrtomb; then gl_FUNC_WCRTOMB - if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then - AC_LIBOBJ([wcrtomb]) + gl_CONDITIONAL([GL_COND_OBJ_WCRTOMB], + [test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1]) + AM_COND_IF([GL_COND_OBJ_WCRTOMB], [ gl_PREREQ_WCRTOMB - fi + ]) gl_WCHAR_MODULE_INDICATOR([wcrtomb]) gl_gnulib_enabled_wcrtomb=true if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then @@ -1464,9 +1564,20 @@ AC_SUBST([LTALLOCA]) if ! $gl_gnulib_enabled_3dcce957eadc896e63ab5f137947b410; then gl_WCTYPE_H gl_WCTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P gl_gnulib_enabled_3dcce957eadc896e63ab5f137947b410=true fi } + func_gl_gnulib_m4code_fd43d02c899a251eacc999baf40b238e () + { + if ! $gl_gnulib_enabled_fd43d02c899a251eacc999baf40b238e; then + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_SPAWN], + [case "$host_os" in mingw*) true;; *) false;; esac]) + gl_gnulib_enabled_fd43d02c899a251eacc999baf40b238e=true + func_gl_gnulib_m4code_7be38c8cf2027003f573b80556d26ff2 + fi + } func_gl_gnulib_m4code_xsize () { if ! $gl_gnulib_enabled_xsize; then @@ -1478,9 +1589,6 @@ AC_SUBST([LTALLOCA]) if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c fi - if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then - func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 - fi if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then func_gl_gnulib_m4code_mempcpy fi @@ -1529,6 +1637,12 @@ AC_SUBST([LTALLOCA]) if test $HAVE_GETADDRINFO = 0 || test $REPLACE_GETADDRINFO = 1; then func_gl_gnulib_m4code_sockets fi + if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then + func_gl_gnulib_m4code_netinet_in + fi + if test $HAVE_INET_PTON = 0 || test $REPLACE_INET_PTON = 1; then + func_gl_gnulib_m4code_netinet_in + fi if test $REPLACE_ISFINITE = 1; then func_gl_gnulib_m4code_b1df7117b479d2da59d76deba468ee21 fi @@ -1580,6 +1694,9 @@ AC_SUBST([LTALLOCA]) if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then func_gl_gnulib_m4code_sockets fi + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + func_gl_gnulib_m4code_332607f759618fb73dfc3076748afea7 + fi if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then func_gl_gnulib_m4code_stat fi @@ -1592,9 +1709,6 @@ AC_SUBST([LTALLOCA]) if test $ac_use_included_regex = yes; then func_gl_gnulib_m4code_dynarray fi - if test $ac_use_included_regex = yes; then - func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 - fi if test $ac_use_included_regex = yes; then func_gl_gnulib_m4code_mbrtowc fi @@ -1647,17 +1761,20 @@ AC_SUBST([LTALLOCA]) func_gl_gnulib_m4code_raise fi m4_pattern_allow([^gl_GNULIB_ENABLED_]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_access], [$gl_gnulib_enabled_access]) AM_CONDITIONAL([gl_GNULIB_ENABLED_alloca], [$gl_gnulib_enabled_alloca]) AM_CONDITIONAL([gl_GNULIB_ENABLED_assure], [$gl_gnulib_enabled_assure]) AM_CONDITIONAL([gl_GNULIB_ENABLED_btowc], [$gl_gnulib_enabled_btowc]) AM_CONDITIONAL([gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547], [$gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547]) AM_CONDITIONAL([gl_GNULIB_ENABLED_chdir], [$gl_gnulib_enabled_chdir]) AM_CONDITIONAL([gl_GNULIB_ENABLED_cloexec], [$gl_gnulib_enabled_cloexec]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_6da965dc4d3aa4f87d68116dce96f1a5], [$gl_gnulib_enabled_6da965dc4d3aa4f87d68116dce96f1a5]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dup2], [$gl_gnulib_enabled_dup2]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dynarray], [$gl_gnulib_enabled_dynarray]) AM_CONDITIONAL([gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c], [$gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c]) AM_CONDITIONAL([gl_GNULIB_ENABLED_fcntl], [$gl_gnulib_enabled_fcntl]) AM_CONDITIONAL([gl_GNULIB_ENABLED_43fe87a341d9b4b93c47c3ad819a5239], [$gl_gnulib_enabled_43fe87a341d9b4b93c47c3ad819a5239]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_7be38c8cf2027003f573b80556d26ff2], [$gl_gnulib_enabled_7be38c8cf2027003f573b80556d26ff2]) AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize]) AM_CONDITIONAL([gl_GNULIB_ENABLED_getrandom], [$gl_gnulib_enabled_getrandom]) AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) @@ -1666,7 +1783,6 @@ AC_SUBST([LTALLOCA]) AM_CONDITIONAL([gl_GNULIB_ENABLED_b1df7117b479d2da59d76deba468ee21], [$gl_gnulib_enabled_b1df7117b479d2da59d76deba468ee21]) AM_CONDITIONAL([gl_GNULIB_ENABLED_3f0e593033d1fc2c127581960f641b66], [$gl_gnulib_enabled_3f0e593033d1fc2c127581960f641b66]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dbdf22868a5367f28bf18e0013ac6f8f], [$gl_gnulib_enabled_dbdf22868a5367f28bf18e0013ac6f8f]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467], [$gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467]) AM_CONDITIONAL([gl_GNULIB_ENABLED_localeconv], [$gl_gnulib_enabled_localeconv]) AM_CONDITIONAL([gl_GNULIB_ENABLED_log], [$gl_gnulib_enabled_log]) AM_CONDITIONAL([gl_GNULIB_ENABLED_mbrtowc], [$gl_gnulib_enabled_mbrtowc]) @@ -1676,7 +1792,9 @@ AC_SUBST([LTALLOCA]) AM_CONDITIONAL([gl_GNULIB_ENABLED_mempcpy], [$gl_gnulib_enabled_mempcpy]) AM_CONDITIONAL([gl_GNULIB_ENABLED_mktime], [$gl_gnulib_enabled_mktime]) AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_netinet_in], [$gl_gnulib_enabled_netinet_in]) AM_CONDITIONAL([gl_GNULIB_ENABLED_pathmax], [$gl_gnulib_enabled_pathmax]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7], [$gl_gnulib_enabled_332607f759618fb73dfc3076748afea7]) AM_CONDITIONAL([gl_GNULIB_ENABLED_raise], [$gl_gnulib_enabled_raise]) AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr]) AM_CONDITIONAL([gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4], [$gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4]) @@ -1685,11 +1803,14 @@ AC_SUBST([LTALLOCA]) AM_CONDITIONAL([gl_GNULIB_ENABLED_scratch_buffer], [$gl_gnulib_enabled_scratch_buffer]) AM_CONDITIONAL([gl_GNULIB_ENABLED_servent], [$gl_gnulib_enabled_servent]) AM_CONDITIONAL([gl_GNULIB_ENABLED_e7e881d32ca02f1c997b13c737c64bbd], [$gl_gnulib_enabled_e7e881d32ca02f1c997b13c737c64bbd]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70], [$gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70]) AM_CONDITIONAL([gl_GNULIB_ENABLED_signbit], [$gl_gnulib_enabled_signbit]) AM_CONDITIONAL([gl_GNULIB_ENABLED_size_max], [$gl_gnulib_enabled_size_max]) AM_CONDITIONAL([gl_GNULIB_ENABLED_snprintf], [$gl_gnulib_enabled_snprintf]) AM_CONDITIONAL([gl_GNULIB_ENABLED_sockets], [$gl_gnulib_enabled_sockets]) AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_stpcpy], [$gl_gnulib_enabled_stpcpy]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_strchrnul], [$gl_gnulib_enabled_strchrnul]) AM_CONDITIONAL([gl_GNULIB_ENABLED_f9850631dca91859e9cddac9359921c0], [$gl_gnulib_enabled_f9850631dca91859e9cddac9359921c0]) AM_CONDITIONAL([gl_GNULIB_ENABLED_streq], [$gl_gnulib_enabled_streq]) AM_CONDITIONAL([gl_GNULIB_ENABLED_sys_random], [$gl_gnulib_enabled_sys_random]) @@ -1701,6 +1822,7 @@ AC_SUBST([LTALLOCA]) AM_CONDITIONAL([gl_GNULIB_ENABLED_vasnprintf], [$gl_gnulib_enabled_vasnprintf]) AM_CONDITIONAL([gl_GNULIB_ENABLED_wcrtomb], [$gl_gnulib_enabled_wcrtomb]) AM_CONDITIONAL([gl_GNULIB_ENABLED_3dcce957eadc896e63ab5f137947b410], [$gl_gnulib_enabled_3dcce957eadc896e63ab5f137947b410]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_fd43d02c899a251eacc999baf40b238e], [$gl_gnulib_enabled_fd43d02c899a251eacc999baf40b238e]) AM_CONDITIONAL([gl_GNULIB_ENABLED_xsize], [$gl_gnulib_enabled_xsize]) # End of code from modules m4_ifval(gl_LIBSOURCES_LIST, [ @@ -1724,16 +1846,28 @@ AC_SUBST([LTALLOCA]) AC_CONFIG_COMMANDS_PRE([ gl_libobjs= gl_ltlibobjs= + gl_libobjdeps= if test -n "$gl_LIBOBJS"; then # Remove the extension. +changequote(,)dnl sed_drop_objext='s/\.o$//;s/\.obj$//' + sed_dirname1='s,//*,/,g' + sed_dirname2='s,\(.\)/$,\1,' + sed_dirname3='s,^[^/]*$,.,' + sed_dirname4='s,\(.\)/[^/]*$,\1,' + sed_basename1='s,.*/,,' +changequote([, ])dnl for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do gl_libobjs="$gl_libobjs $i.$ac_objext" gl_ltlibobjs="$gl_ltlibobjs $i.lo" + i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` + i_base=`echo "$i" | sed -e "$sed_basename1"` + gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Plo" done fi AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) + AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps]) ]) gltests_libdeps= gltests_ltlibdeps= @@ -1746,6 +1880,7 @@ AC_SUBST([LTALLOCA]) m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) gl_COMMON gl_source_base='tests' + gl_source_base_prefix= changequote(,)dnl gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS changequote([, ])dnl @@ -1775,17 +1910,30 @@ changequote([, ])dnl AC_CONFIG_COMMANDS_PRE([ gltests_libobjs= gltests_ltlibobjs= + gltests_libobjdeps= if test -n "$gltests_LIBOBJS"; then # Remove the extension. +changequote(,)dnl sed_drop_objext='s/\.o$//;s/\.obj$//' + sed_dirname1='s,//*,/,g' + sed_dirname2='s,\(.\)/$,\1,' + sed_dirname3='s,^[^/]*$,.,' + sed_dirname4='s,\(.\)/[^/]*$,\1,' + sed_basename1='s,.*/,,' +changequote([, ])dnl for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do gltests_libobjs="$gltests_libobjs $i.$ac_objext" gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" + i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` + i_base=`echo "$i" | sed -e "$sed_basename1"` + gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Plo" done fi AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) + AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps]) ]) + AC_REQUIRE([gl_CC_GNULIB_WARNINGS]) ]) # Like AC_LIBOBJ, except that the module name goes @@ -1859,6 +2007,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/_Noreturn.h lib/accept.c lib/accept4.c + lib/access.c lib/alignof.h lib/alloca.c lib/alloca.in.h @@ -1887,6 +2036,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/cloexec.c lib/cloexec.h lib/close.c + lib/concat-filename.c + lib/concat-filename.h lib/connect.c lib/copysign.c lib/dirent.in.h @@ -1903,6 +2054,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/fd-hook.c lib/fd-hook.h lib/filename.h + lib/findprog-in.c + lib/findprog.h lib/flexmember.h lib/float+.h lib/float.c @@ -1942,6 +2095,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/idx.h lib/inet_ntop.c lib/inet_pton.c + lib/intprops-internal.h lib/intprops.h lib/inttypes.in.h lib/isfinite.c @@ -2046,6 +2200,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/safe-write.c lib/safe-write.h lib/same-inode.h + lib/sched.in.h lib/scratch_buffer.h lib/select.c lib/send.c @@ -2065,6 +2220,10 @@ AC_DEFUN([gl_FILE_LIST], [ lib/socket.c lib/sockets.c lib/sockets.h + lib/spawn.in.h + lib/spawn_int.h + lib/spawni.c + lib/spawnp.c lib/stat-time.c lib/stat-time.h lib/stat-w32.c @@ -2072,10 +2231,16 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stat.c lib/stdalign.in.h lib/stdbool.in.h + lib/stdckdint.in.h lib/stddef.in.h lib/stdint.in.h + lib/stdio-read.c + lib/stdio-write.c lib/stdio.in.h lib/stdlib.in.h + lib/stpcpy.c + lib/strchrnul.c + lib/strchrnul.valgrind lib/strdup.c lib/streq.h lib/strftime.h @@ -2118,6 +2283,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/wctype-h.c lib/wctype.in.h lib/windows-initguard.h + lib/windows-spawn.c + lib/windows-spawn.h lib/write.c lib/xalloc-oversized.h lib/xsize.c @@ -2126,6 +2293,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/__inline.m4 m4/absolute-header.m4 m4/accept4.m4 + m4/access.m4 m4/alloca.m4 m4/arpa_inet_h.m4 m4/autobuild.m4 @@ -2144,6 +2312,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/double-slash-root.m4 m4/dup2.m4 m4/duplocale.m4 + m4/eaccess.m4 m4/eealloc.m4 m4/environ.m4 m4/errno_h.m4 @@ -2155,6 +2324,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/fcntl-o.m4 m4/fcntl.m4 m4/fcntl_h.m4 + m4/findprog-in.m4 m4/flexmember.m4 m4/float_h.m4 m4/flock.m4 @@ -2242,6 +2412,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/pipe2.m4 m4/poll.m4 m4/poll_h.m4 + m4/posix_spawn.m4 m4/printf.m4 m4/putenv.m4 m4/raise.m4 @@ -2255,10 +2426,12 @@ AC_DEFUN([gl_FILE_LIST], [ m4/round.m4 m4/safe-read.m4 m4/safe-write.m4 + m4/sched_h.m4 m4/select.m4 m4/servent.m4 m4/setenv.m4 m4/setlocale_null.m4 + m4/sh-filename.m4 m4/signal_h.m4 m4/signbit.m4 m4/size_max.m4 @@ -2267,6 +2440,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/sockets.m4 m4/socklen.m4 m4/sockpfaf.m4 + m4/spawn_h.m4 m4/ssize_t.m4 m4/stat-time.m4 m4/stat.m4 @@ -2278,6 +2452,8 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stdint_h.m4 m4/stdio_h.m4 m4/stdlib_h.m4 + m4/stpcpy.m4 + m4/strchrnul.m4 m4/strdup.m4 m4/string_h.m4 m4/sys_file_h.m4 @@ -2300,6 +2476,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/trunc.m4 m4/tzset.m4 m4/unistd_h.m4 + m4/vararrays.m4 m4/vasnprintf.m4 m4/visibility.m4 m4/vsnprintf.m4 diff --git a/m4/gnulib-tool.m4 b/m4/gnulib-tool.m4 index 3d56d83f1..8428901c3 100644 --- a/m4/gnulib-tool.m4 +++ b/m4/gnulib-tool.m4 @@ -1,5 +1,5 @@ -# gnulib-tool.m4 serial 2 -dnl Copyright (C) 2004-2005, 2009-2021 Free Software Foundation, Inc. +# gnulib-tool.m4 serial 4 +dnl Copyright (C) 2004-2005, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -44,6 +44,12 @@ AC_DEFUN([gl_LGPL], []) dnl Usage: gl_MAKEFILE_NAME([FILENAME]) AC_DEFUN([gl_MAKEFILE_NAME], []) +dnl Usage: gl_TESTS_MAKEFILE_NAME([FILENAME]) +AC_DEFUN([gl_TESTS_MAKEFILE_NAME], []) + +dnl Usage: gl_AUTOMAKE_SUBDIR +AC_DEFUN([gl_AUTOMAKE_SUBDIR], []) + dnl Usage: gl_LIBTOOL AC_DEFUN([gl_LIBTOOL], []) diff --git a/m4/host-cpu-c-abi.m4 b/m4/host-cpu-c-abi.m4 index 64e28b1d3..b9223241b 100644 --- a/m4/host-cpu-c-abi.m4 +++ b/m4/host-cpu-c-abi.m4 @@ -1,5 +1,5 @@ -# host-cpu-c-abi.m4 serial 14 -dnl Copyright (C) 2002-2021 Free Software Foundation, Inc. +# host-cpu-c-abi.m4 serial 15 +dnl Copyright (C) 2002-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -382,6 +382,9 @@ EOF #ifndef __ia64__ #undef __ia64__ #endif +#ifndef __loongarch64__ +#undef __loongarch64__ +#endif #ifndef __m68k__ #undef __m68k__ #endif diff --git a/m4/hostent.m4 b/m4/hostent.m4 index f1390a32e..69fc5ac1a 100644 --- a/m4/hostent.m4 +++ b/m4/hostent.m4 @@ -1,5 +1,5 @@ # hostent.m4 serial 4 -dnl Copyright (C) 2008, 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008, 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/iconv.m4 b/m4/iconv.m4 index d0e61de26..2065c9772 100644 --- a/m4/iconv.m4 +++ b/m4/iconv.m4 @@ -1,5 +1,5 @@ -# iconv.m4 serial 24 -dnl Copyright (C) 2000-2002, 2007-2014, 2016-2021 Free Software Foundation, +# iconv.m4 serial 26 +dnl Copyright (C) 2000-2002, 2007-2014, 2016-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -234,12 +234,6 @@ AC_DEFUN([AM_ICONV_LINK], dnl Define AM_ICONV using AC_DEFUN_ONCE, in order to avoid warnings like dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". -dnl This is tricky because of the way 'aclocal' is implemented: -dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. -dnl Otherwise aclocal's initial scan pass would miss the macro definition. -dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. -dnl Otherwise aclocal would emit many "Use of uninitialized value $1" -dnl warnings. AC_DEFUN_ONCE([AM_ICONV], [ AM_ICONV_LINK @@ -280,4 +274,20 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si ICONV_CONST="const" fi ]) + + dnl A summary result, for those packages which want to print a summary at the + dnl end of the configuration. + if test "$am_func_iconv" = yes; then + if test -n "$LIBICONV"; then + am_cv_func_iconv_summary='yes, in libiconv' + else + am_cv_func_iconv_summary='yes, in libc' + fi + else + if test "$am_cv_func_iconv" = yes; then + am_cv_func_iconv_summary='not working, consider installing GNU libiconv' + else + am_cv_func_iconv_summary='no, consider installing GNU libiconv' + fi + fi ]) diff --git a/m4/iconv_h.m4 b/m4/iconv_h.m4 index 294098829..584656628 100644 --- a/m4/iconv_h.m4 +++ b/m4/iconv_h.m4 @@ -1,5 +1,5 @@ -# iconv_h.m4 serial 15 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +# iconv_h.m4 serial 16 +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -8,8 +8,8 @@ AC_DEFUN_ONCE([gl_ICONV_H], [ AC_REQUIRE([gl_ICONV_H_DEFAULTS]) - dnl Execute this unconditionally, because ICONV_H may be set by other - dnl modules, after this code is executed. + dnl Execute this unconditionally, because GL_GENERATE_ICONV_H may be set to + dnl true by other modules, after this code is executed. gl_CHECK_NEXT_HEADERS([iconv.h]) dnl Check for declarations of anything we want to poison if the @@ -25,8 +25,7 @@ dnl Unconditionally enables the replacement of . AC_DEFUN([gl_REPLACE_ICONV_H], [ gl_ICONV_H_REQUIRE_DEFAULTS - ICONV_H='iconv.h' - AM_CONDITIONAL([GL_GENERATE_ICONV_H], [test -n "$ICONV_H"]) + GL_GENERATE_ICONV_H=true ]) # gl_ICONV_MODULE_INDICATOR([modulename]) @@ -60,13 +59,12 @@ AC_DEFUN([gl_ICONV_H_DEFAULTS], REPLACE_ICONV=0; AC_SUBST([REPLACE_ICONV]) REPLACE_ICONV_OPEN=0; AC_SUBST([REPLACE_ICONV_OPEN]) REPLACE_ICONV_UTF=0; AC_SUBST([REPLACE_ICONV_UTF]) - ICONV_H=''; AC_SUBST([ICONV_H]) + GL_GENERATE_ICONV_H=false m4_ifdef([gl_POSIXCHECK], - [ICONV_H='iconv.h'], + [GL_GENERATE_ICONV_H=true], [if m4_ifdef([gl_ANSI_CXX], [test "$CXX" != no], [false]); then dnl Override always, to support the C++ GNULIB_NAMESPACE. - ICONV_H='iconv.h' + GL_GENERATE_ICONV_H=true fi ]) - AM_CONDITIONAL([GL_GENERATE_ICONV_H], [test -n "$ICONV_H"]) ]) diff --git a/m4/iconv_open-utf.m4 b/m4/iconv_open-utf.m4 index 68efaf9da..282c2b7e7 100644 --- a/m4/iconv_open-utf.m4 +++ b/m4/iconv_open-utf.m4 @@ -1,5 +1,5 @@ # iconv_open-utf.m4 serial 4 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/iconv_open.m4 b/m4/iconv_open.m4 index 61b6af487..1ed26cd82 100644 --- a/m4/iconv_open.m4 +++ b/m4/iconv_open.m4 @@ -1,5 +1,5 @@ # iconv_open.m4 serial 16 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/include_next.m4 b/m4/include_next.m4 index bdd542bc6..a9247f6f1 100644 --- a/m4/include_next.m4 +++ b/m4/include_next.m4 @@ -1,5 +1,5 @@ # include_next.m4 serial 26 -dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -193,9 +193,9 @@ AC_DEFUN([gl_NEXT_HEADERS_INTERNAL], if test AS_VAR_GET([gl_header_exists]) = yes; then AS_VAR_POPDEF([gl_header_exists]) ]) - gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME) - AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME)) - AS_VAR_SET([gl_next_header], ['"'$gl_header'"']) + gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME) + AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME)) + AS_VAR_SET([gl_next_header], ['"'$gl_header'"']) m4_if([$2], [check], [else AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) diff --git a/m4/inet_ntop.m4 b/m4/inet_ntop.m4 index 171f53ee7..c335cae7e 100644 --- a/m4/inet_ntop.m4 +++ b/m4/inet_ntop.m4 @@ -1,5 +1,5 @@ # inet_ntop.m4 serial 21 -dnl Copyright (C) 2005-2006, 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/inet_pton.m4 b/m4/inet_pton.m4 index 197917910..9507296d3 100644 --- a/m4/inet_pton.m4 +++ b/m4/inet_pton.m4 @@ -1,5 +1,5 @@ # inet_pton.m4 serial 19 -dnl Copyright (C) 2006, 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2006, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4 new file mode 100644 index 000000000..289c4df5e --- /dev/null +++ b/m4/intdiv0.m4 @@ -0,0 +1,84 @@ +# intdiv0.m4 serial 3 (gettext-0.18) +dnl Copyright (C) 2002, 2007-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gt_INTDIV0], +[ + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + + AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], + gt_cv_int_divbyzero_sigfpe, + [ + gt_cv_int_divbyzero_sigfpe= +changequote(,)dnl + case "$host_os" in + macos* | darwin[6-9]* | darwin[1-9][0-9]*) + # On MacOS X 10.2 or newer, just assume the same as when cross- + # compiling. If we were to perform the real test, 1 Crash Report + # dialog window would pop up. + case "$host_cpu" in + i[34567]86 | x86_64) + gt_cv_int_divbyzero_sigfpe="guessing yes" ;; + esac + ;; + esac +changequote([,])dnl + if test -z "$gt_cv_int_divbyzero_sigfpe"; then + AC_TRY_RUN([ +#include +#include + +static void +sigfpe_handler (int sig) +{ + /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ + exit (sig != SIGFPE); +} + +int x = 1; +int y = 0; +int z; +int nan; + +int main () +{ + signal (SIGFPE, sigfpe_handler); +/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ +#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) + signal (SIGTRAP, sigfpe_handler); +#endif +/* Linux/SPARC yields signal SIGILL. */ +#if defined (__sparc__) && defined (__linux__) + signal (SIGILL, sigfpe_handler); +#endif + + z = x / y; + nan = y / y; + exit (1); +} +], [gt_cv_int_divbyzero_sigfpe=yes], [gt_cv_int_divbyzero_sigfpe=no], + [ + # Guess based on the CPU. +changequote(,)dnl + case "$host_cpu" in + alpha* | i[34567]86 | x86_64 | m68k | s390*) + gt_cv_int_divbyzero_sigfpe="guessing yes";; + *) + gt_cv_int_divbyzero_sigfpe="guessing no";; + esac +changequote([,])dnl + ]) + fi + ]) + case "$gt_cv_int_divbyzero_sigfpe" in + *yes) value=1;; + *) value=0;; + esac + AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value], + [Define if integer division by zero raises signal SIGFPE.]) +]) diff --git a/m4/intl.m4 b/m4/intl.m4 new file mode 100644 index 000000000..335b23c20 --- /dev/null +++ b/m4/intl.m4 @@ -0,0 +1,294 @@ +# intl.m4 serial 17 (gettext-0.18) +dnl Copyright (C) 1995-2009 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2009. + +AC_PREREQ([2.52]) + +dnl Checks for all prerequisites of the intl subdirectory, +dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, +dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. +AC_DEFUN([AM_INTL_SUBDIR], +[ + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + AC_REQUIRE([gt_GLIBC2])dnl + AC_REQUIRE([AC_PROG_RANLIB])dnl + AC_REQUIRE([gl_VISIBILITY])dnl + AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl + AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl + AC_REQUIRE([gt_TYPE_WCHAR_T])dnl + AC_REQUIRE([gt_TYPE_WINT_T])dnl + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gt_TYPE_INTMAX_T]) + AC_REQUIRE([gt_PRINTF_POSIX]) + AC_REQUIRE([gl_GLIBC21])dnl + AC_REQUIRE([gl_XSIZE])dnl + AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl + AC_REQUIRE([gt_INTL_MACOSX])dnl + + dnl Support for automake's --enable-silent-rules. + case "$enable_silent_rules" in + yes) INTL_DEFAULT_VERBOSITY=0;; + no) INTL_DEFAULT_VERBOSITY=1;; + *) INTL_DEFAULT_VERBOSITY=1;; + esac + AC_SUBST([INTL_DEFAULT_VERBOSITY]) + + AC_CHECK_TYPE([ptrdiff_t], , + [AC_DEFINE([ptrdiff_t], [long], + [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) + ]) + AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) + AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \ + snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) + + dnl Use the _snprintf function only if it is declared (because on NetBSD it + dnl is defined as a weak alias of snprintf; we prefer to use the latter). + gt_CHECK_DECL(_snprintf, [#include ]) + gt_CHECK_DECL(_snwprintf, [#include ]) + + dnl Use the *_unlocked functions only if they are declared. + dnl (because some of them were defined without being declared in Solaris + dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built + dnl on Solaris 2.5.1 to run on Solaris 2.6). + dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. + gt_CHECK_DECL(getc_unlocked, [#include ]) + + case $gt_cv_func_printf_posix in + *yes) HAVE_POSIX_PRINTF=1 ;; + *) HAVE_POSIX_PRINTF=0 ;; + esac + AC_SUBST([HAVE_POSIX_PRINTF]) + if test "$ac_cv_func_asprintf" = yes; then + HAVE_ASPRINTF=1 + else + HAVE_ASPRINTF=0 + fi + AC_SUBST([HAVE_ASPRINTF]) + if test "$ac_cv_func_snprintf" = yes; then + HAVE_SNPRINTF=1 + else + HAVE_SNPRINTF=0 + fi + AC_SUBST([HAVE_SNPRINTF]) + if test "$ac_cv_func_newlocale" = yes; then + HAVE_NEWLOCALE=1 + else + HAVE_NEWLOCALE=0 + fi + AC_SUBST([HAVE_NEWLOCALE]) + if test "$ac_cv_func_wprintf" = yes; then + HAVE_WPRINTF=1 + else + HAVE_WPRINTF=0 + fi + AC_SUBST([HAVE_WPRINTF]) + + AM_LANGINFO_CODESET + gt_LC_MESSAGES + + dnl Compilation on mingw and Cygwin needs special Makefile rules, because + dnl 1. when we install a shared library, we must arrange to export + dnl auxiliary pointer variables for every exported variable, + dnl 2. when we install a shared library and a static library simultaneously, + dnl the include file specifies __declspec(dllimport) and therefore we + dnl must arrange to define the auxiliary pointer variables for the + dnl exported variables _also_ in the static library. + if test "$enable_shared" = yes; then + case "$host_os" in + mingw* | cygwin*) is_woe32dll=yes ;; + *) is_woe32dll=no ;; + esac + else + is_woe32dll=no + fi + WOE32DLL=$is_woe32dll + AC_SUBST([WOE32DLL]) + + dnl On mingw and Cygwin, we can activate special Makefile rules which add + dnl version information to the shared libraries and executables. + case "$host_os" in + mingw* | cygwin*) is_woe32=yes ;; + *) is_woe32=no ;; + esac + WOE32=$is_woe32 + AC_SUBST([WOE32]) + if test $WOE32 = yes; then + dnl Check for a program that compiles Windows resource files. + AC_CHECK_TOOL([WINDRES], [windres]) + fi + + dnl Determine whether when creating a library, "-lc" should be passed to + dnl libtool or not. On many platforms, it is required for the libtool option + dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool + dnl in the *.la files - makes it impossible to create multithreaded programs, + dnl because libtool also reorders the -lc to come before the -pthread, and + dnl this disables pthread_create() . + case "$host_os" in + hpux*) LTLIBC="" ;; + *) LTLIBC="-lc" ;; + esac + AC_SUBST([LTLIBC]) + + dnl Rename some macros and functions used for locking. + AH_BOTTOM([ +#define __libc_lock_t gl_lock_t +#define __libc_lock_define gl_lock_define +#define __libc_lock_define_initialized gl_lock_define_initialized +#define __libc_lock_init gl_lock_init +#define __libc_lock_lock gl_lock_lock +#define __libc_lock_unlock gl_lock_unlock +#define __libc_lock_recursive_t gl_recursive_lock_t +#define __libc_lock_define_recursive gl_recursive_lock_define +#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized +#define __libc_lock_init_recursive gl_recursive_lock_init +#define __libc_lock_lock_recursive gl_recursive_lock_lock +#define __libc_lock_unlock_recursive gl_recursive_lock_unlock +#define glthread_in_use libintl_thread_in_use +#define glthread_lock_init_func libintl_lock_init_func +#define glthread_lock_lock_func libintl_lock_lock_func +#define glthread_lock_unlock_func libintl_lock_unlock_func +#define glthread_lock_destroy_func libintl_lock_destroy_func +#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded +#define glthread_rwlock_init_func libintl_rwlock_init_func +#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded +#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func +#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded +#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func +#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded +#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func +#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded +#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func +#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded +#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func +#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded +#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func +#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded +#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func +#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded +#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func +#define glthread_once_func libintl_once_func +#define glthread_once_singlethreaded libintl_once_singlethreaded +#define glthread_once_multithreaded libintl_once_multithreaded +]) +]) + + +dnl Checks for the core files of the intl subdirectory: +dnl dcigettext.c +dnl eval-plural.h +dnl explodename.c +dnl finddomain.c +dnl gettextP.h +dnl gmo.h +dnl hash-string.h hash-string.c +dnl l10nflist.c +dnl libgnuintl.h.in (except the *printf stuff) +dnl loadinfo.h +dnl loadmsgcat.c +dnl localealias.c +dnl log.c +dnl plural-exp.h plural-exp.c +dnl plural.y +dnl Used by libglocale. +AC_DEFUN([gt_INTL_SUBDIR_CORE], +[ + AC_REQUIRE([AC_C_INLINE])dnl + AC_REQUIRE([AC_TYPE_SIZE_T])dnl + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + AC_REQUIRE([AC_FUNC_ALLOCA])dnl + AC_REQUIRE([AC_FUNC_MMAP])dnl + AC_REQUIRE([gt_INTDIV0])dnl + AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl + AC_REQUIRE([gt_INTTYPES_PRI])dnl + AC_REQUIRE([gl_LOCK])dnl + + AC_TRY_LINK( + [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], + [], + [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], + [Define to 1 if the compiler understands __builtin_expect.])]) + + AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) + AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ + stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \ + argz_stringify argz_next __fsetlocking]) + + dnl Use the *_unlocked functions only if they are declared. + dnl (because some of them were defined without being declared in Solaris + dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built + dnl on Solaris 2.5.1 to run on Solaris 2.6). + dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. + gt_CHECK_DECL([feof_unlocked], [#include ]) + gt_CHECK_DECL([fgets_unlocked], [#include ]) + + AM_ICONV + + dnl intl/plural.c is generated from intl/plural.y. It requires bison, + dnl because plural.y uses bison specific features. It requires at least + dnl bison-1.26 because earlier versions generate a plural.c that doesn't + dnl compile. + dnl bison is only needed for the maintainer (who touches plural.y). But in + dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put + dnl the rule in general Makefile. Now, some people carelessly touch the + dnl files or have a broken "make" program, hence the plural.c rule will + dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not + dnl present or too old. + AC_CHECK_PROGS([INTLBISON], [bison]) + if test -z "$INTLBISON"; then + ac_verc_fail=yes + else + dnl Found it, now check the version. + AC_MSG_CHECKING([version of bison]) +changequote(<<,>>)dnl + ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; + 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) +changequote([,])dnl + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; + esac + AC_MSG_RESULT([$ac_prog_version]) + fi + if test $ac_verc_fail = yes; then + INTLBISON=: + fi +]) + + +dnl gt_CHECK_DECL(FUNC, INCLUDES) +dnl Check whether a function is declared. +AC_DEFUN([gt_CHECK_DECL], +[ + AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1], + [AC_TRY_COMPILE([$2], [ +#ifndef $1 + char *p = (char *) $1; +#endif +], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)]) + if test $ac_cv_have_decl_$1 = yes; then + gt_value=1 + else + gt_value=0 + fi + AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value], + [Define to 1 if you have the declaration of `$1', and to 0 if you don't.]) +]) diff --git a/m4/intldir.m4 b/m4/intldir.m4 new file mode 100644 index 000000000..ebae76d36 --- /dev/null +++ b/m4/intldir.m4 @@ -0,0 +1,19 @@ +# intldir.m4 serial 2 (gettext-0.18) +dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +AC_PREREQ([2.52]) + +dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory. +AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], []) diff --git a/m4/intlmacosx.m4 b/m4/intlmacosx.m4 new file mode 100644 index 000000000..dd9102596 --- /dev/null +++ b/m4/intlmacosx.m4 @@ -0,0 +1,51 @@ +# intlmacosx.m4 serial 3 (gettext-0.18) +dnl Copyright (C) 2004-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Checks for special options needed on MacOS X. +dnl Defines INTL_MACOSX_LIBS. +AC_DEFUN([gt_INTL_MACOSX], +[ + dnl Check for API introduced in MacOS X 10.2. + AC_CACHE_CHECK([for CFPreferencesCopyAppValue], + [gt_cv_func_CFPreferencesCopyAppValue], + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_TRY_LINK([#include ], + [CFPreferencesCopyAppValue(NULL, NULL)], + [gt_cv_func_CFPreferencesCopyAppValue=yes], + [gt_cv_func_CFPreferencesCopyAppValue=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then + AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], + [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) + fi + dnl Check for API introduced in MacOS X 10.3. + AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_TRY_LINK([#include ], [CFLocaleCopyCurrent();], + [gt_cv_func_CFLocaleCopyCurrent=yes], + [gt_cv_func_CFLocaleCopyCurrent=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFLocaleCopyCurrent = yes; then + AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], + [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) + fi + INTL_MACOSX_LIBS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then + INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + AC_SUBST([INTL_MACOSX_LIBS]) +]) diff --git a/m4/intmax.m4 b/m4/intmax.m4 new file mode 100644 index 000000000..74aaaf5ed --- /dev/null +++ b/m4/intmax.m4 @@ -0,0 +1,33 @@ +# intmax.m4 serial 5 (gettext-0.18) +dnl Copyright (C) 2002-2005, 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether the system has the 'intmax_t' type, but don't attempt to +dnl find a replacement if it is lacking. + +AC_DEFUN([gt_TYPE_INTMAX_T], +[ + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], + [AC_TRY_COMPILE([ +#include +#include +#if HAVE_STDINT_H_WITH_UINTMAX +#include +#endif +#if HAVE_INTTYPES_H_WITH_UINTMAX +#include +#endif +], [intmax_t x = -1; + return !x;], + [gt_cv_c_intmax_t=yes], + [gt_cv_c_intmax_t=no])]) + if test $gt_cv_c_intmax_t = yes; then + AC_DEFINE([HAVE_INTMAX_T], [1], + [Define if you have the 'intmax_t' type in or .]) + fi +]) diff --git a/m4/intmax_t.m4 b/m4/intmax_t.m4 index 63c4b415d..8a15dabdf 100644 --- a/m4/intmax_t.m4 +++ b/m4/intmax_t.m4 @@ -1,5 +1,5 @@ # intmax_t.m4 serial 9 -dnl Copyright (C) 1997-2004, 2006-2007, 2009-2021 Free Software Foundation, +dnl Copyright (C) 1997-2004, 2006-2007, 2009-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/inttypes-pri.m4 b/m4/inttypes-pri.m4 new file mode 100644 index 000000000..718a4f4e1 --- /dev/null +++ b/m4/inttypes-pri.m4 @@ -0,0 +1,36 @@ +# inttypes-pri.m4 serial 6 (gettext-0.18) +dnl Copyright (C) 1997-2002, 2006, 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_PREREQ([2.52]) + +# Define PRI_MACROS_BROKEN if exists and defines the PRI* +# macros to non-string values. This is the case on AIX 4.3.3. + +AC_DEFUN([gt_INTTYPES_PRI], +[ + AC_CHECK_HEADERS([inttypes.h]) + if test $ac_cv_header_inttypes_h = yes; then + AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], + [gt_cv_inttypes_pri_broken], + [ + AC_TRY_COMPILE([#include +#ifdef PRId32 +char *p = PRId32; +#endif +], [], [gt_cv_inttypes_pri_broken=no], [gt_cv_inttypes_pri_broken=yes]) + ]) + fi + if test "$gt_cv_inttypes_pri_broken" = yes; then + AC_DEFINE_UNQUOTED([PRI_MACROS_BROKEN], [1], + [Define if exists and defines unusable PRI* macros.]) + PRI_MACROS_BROKEN=1 + else + PRI_MACROS_BROKEN=0 + fi + AC_SUBST([PRI_MACROS_BROKEN]) +]) diff --git a/m4/inttypes.m4 b/m4/inttypes.m4 index 64b1de5c4..df25a21eb 100644 --- a/m4/inttypes.m4 +++ b/m4/inttypes.m4 @@ -1,5 +1,5 @@ -# inttypes.m4 serial 35 -dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. +# inttypes.m4 serial 36 +dnl Copyright (C) 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -36,7 +36,7 @@ AC_DEFUN_ONCE([gl_INTTYPES_INCOMPLETE], AC_DEFUN([gl_INTTYPES_PRI_SCN], [ PRIPTR_PREFIX= - if test -n "$STDINT_H"; then + if $GL_GENERATE_STDINT_H; then dnl Using the gnulib . It defines intptr_t to 'long' or dnl 'long long', depending on _WIN64. AC_COMPILE_IFELSE( diff --git a/m4/inttypes_h.m4 b/m4/inttypes_h.m4 index 672a93e09..6e9eebf1b 100644 --- a/m4/inttypes_h.m4 +++ b/m4/inttypes_h.m4 @@ -1,5 +1,5 @@ # inttypes_h.m4 serial 10 -dnl Copyright (C) 1997-2004, 2006, 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 1997-2004, 2006, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/isfinite.m4 b/m4/isfinite.m4 index 2b8902d4a..e6325f952 100644 --- a/m4/isfinite.m4 +++ b/m4/isfinite.m4 @@ -1,5 +1,5 @@ # isfinite.m4 serial 17 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/isinf.m4 b/m4/isinf.m4 index ad6ef47ce..6f0029324 100644 --- a/m4/isinf.m4 +++ b/m4/isinf.m4 @@ -1,5 +1,5 @@ # isinf.m4 serial 13 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/isnan.m4 b/m4/isnan.m4 index e0bc03f98..4ae6ed711 100644 --- a/m4/isnan.m4 +++ b/m4/isnan.m4 @@ -1,5 +1,5 @@ # isnan.m4 serial 5 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/isnand.m4 b/m4/isnand.m4 index fc79f0b0c..4eadde7cb 100644 --- a/m4/isnand.m4 +++ b/m4/isnand.m4 @@ -1,5 +1,5 @@ # isnand.m4 serial 12 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/isnanf.m4 b/m4/isnanf.m4 index d0f6a5623..44c825a1f 100644 --- a/m4/isnanf.m4 +++ b/m4/isnanf.m4 @@ -1,5 +1,5 @@ # isnanf.m4 serial 18 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/isnanl.m4 b/m4/isnanl.m4 index 1ef16f5e3..fa49a644f 100644 --- a/m4/isnanl.m4 +++ b/m4/isnanl.m4 @@ -1,5 +1,5 @@ # isnanl.m4 serial 22 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/langinfo_h.m4 b/m4/langinfo_h.m4 index 87959f77a..563c8c431 100644 --- a/m4/langinfo_h.m4 +++ b/m4/langinfo_h.m4 @@ -1,5 +1,5 @@ # langinfo_h.m4 serial 12 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/largefile.m4 b/m4/largefile.m4 index fbde5e664..ec9677c46 100644 --- a/m4/largefile.m4 +++ b/m4/largefile.m4 @@ -1,7 +1,7 @@ # Enable large files on systems where this is not the default. # Enable support for files on Linux file systems with 64-bit inode numbers. -# Copyright 1992-1996, 1998-2021 Free Software Foundation, Inc. +# Copyright 1992-1996, 1998-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -10,8 +10,10 @@ # It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this # setting of _LARGEFILE_SOURCE is needed so that declares fseeko # and ftello in C++ mode as well. +# Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038. AC_DEFUN([gl_SET_LARGEFILE_SOURCE], [ + m4_ifndef([AC_SYS_YEAR2038], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_FUNC_FSEEKO case "$host_os" in @@ -20,9 +22,10 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE], [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).]) ;; esac + ]) ]) -# Work around a problem in Autoconf through at least 2.71 on glibc 2.34+ +# Work around a problem in Autoconf through 2.71 on glibc 2.34+ # with _TIME_BITS. Also, work around a problem in autoconf <= 2.69: # AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, # or configures them incorrectly in some cases. @@ -43,6 +46,7 @@ m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], ]) ])# m4_version_prereq 2.70 +m4_ifndef([AC_SYS_YEAR2038], [ # _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, # CACHE-VAR, @@ -118,6 +122,7 @@ AS_IF([test "$enable_largefile" != no], [64], [gl_YEAR2038_BODY([])])]) ])# AC_SYS_LARGEFILE +])# m4_ifndef AC_SYS_YEAR2038 # Enable large files on systems where this is implemented by Gnulib, not by the # system headers. diff --git a/m4/lcmessage.m4 b/m4/lcmessage.m4 new file mode 100644 index 000000000..1a705431a --- /dev/null +++ b/m4/lcmessage.m4 @@ -0,0 +1,31 @@ +# lcmessage.m4 serial 6 (gettext-0.18) +dnl Copyright (C) 1995-2002, 2004-2005, 2008-2010 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995. + +# Check whether LC_MESSAGES is available in . + +AC_DEFUN([gt_LC_MESSAGES], +[ + AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES], + [AC_TRY_LINK([#include ], [return LC_MESSAGES], + [gt_cv_val_LC_MESSAGES=yes], [gt_cv_val_LC_MESSAGES=no])]) + if test $gt_cv_val_LC_MESSAGES = yes; then + AC_DEFINE([HAVE_LC_MESSAGES], [1], + [Define if your file defines LC_MESSAGES.]) + fi +]) diff --git a/m4/ld-version-script.m4 b/m4/ld-version-script.m4 index 98126d9af..bf81b496d 100644 --- a/m4/ld-version-script.m4 +++ b/m4/ld-version-script.m4 @@ -1,5 +1,5 @@ # ld-version-script.m4 serial 5 -dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/ldexp.m4 b/m4/ldexp.m4 index cb7ce6422..b07dc0550 100644 --- a/m4/ldexp.m4 +++ b/m4/ldexp.m4 @@ -1,5 +1,5 @@ # ldexp.m4 serial 1 -dnl Copyright (C) 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4 index 076358d5d..934207a76 100644 --- a/m4/lib-ld.m4 +++ b/m4/lib-ld.m4 @@ -1,5 +1,5 @@ # lib-ld.m4 serial 10 -dnl Copyright (C) 1996-2003, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 1996-2003, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/lib-link.m4 b/m4/lib-link.m4 index 787efab2d..3b75bcd0d 100644 --- a/m4/lib-link.m4 +++ b/m4/lib-link.m4 @@ -1,5 +1,5 @@ -# lib-link.m4 serial 32 -dnl Copyright (C) 2001-2021 Free Software Foundation, Inc. +# lib-link.m4 serial 33 +dnl Copyright (C) 2001-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -196,8 +196,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" ]) AC_ARG_WITH(PACK[-prefix], -[[ --with-]]PACK[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib - --without-]]PACK[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], +[[ --with-]]PACK[[-prefix[=DIR] search for ]]PACKLIBS[[ in DIR/include and DIR/lib + --without-]]PACK[[-prefix don't search for ]]PACKLIBS[[ in includedir and libdir]], [ if test "X$withval" = "Xno"; then use_additional=no diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 index 3c94db0ac..999f712f5 100644 --- a/m4/lib-prefix.m4 +++ b/m4/lib-prefix.m4 @@ -1,5 +1,5 @@ -# lib-prefix.m4 serial 19 -dnl Copyright (C) 2001-2005, 2008-2021 Free Software Foundation, Inc. +# lib-prefix.m4 serial 20 +dnl Copyright (C) 2001-2005, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -174,7 +174,7 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB], AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf], [AC_EGREP_CPP([Extensible Linking Format], - [#ifdef __ELF__ + [#if defined __ELF__ || (defined __linux__ && defined __EDG__) Extensible Linking Format #endif ], diff --git a/m4/libunistring.m4 b/m4/libunistring.m4 index e3d944793..3c18edbb7 100644 --- a/m4/libunistring.m4 +++ b/m4/libunistring.m4 @@ -1,5 +1,5 @@ # libunistring.m4 serial 12 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/limits-h.m4 b/m4/limits-h.m4 index 00c9fe9e5..5d5a5bf58 100644 --- a/m4/limits-h.m4 +++ b/m4/limits-h.m4 @@ -1,6 +1,6 @@ dnl Check whether limits.h has needed features. -dnl Copyright 2016-2021 Free Software Foundation, Inc. +dnl Copyright 2016-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -27,18 +27,15 @@ AC_DEFUN_ONCE([gl_LIMITS_H], [gl_cv_header_limits_width=yes], [gl_cv_header_limits_width=no])]) if test "$gl_cv_header_limits_width" = yes; then - LIMITS_H= + GL_GENERATE_LIMITS_H=false else - LIMITS_H=limits.h + GL_GENERATE_LIMITS_H=true fi - AC_SUBST([LIMITS_H]) - AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"]) ]) dnl Unconditionally enables the replacement of . AC_DEFUN([gl_REPLACE_LIMITS_H], [ AC_REQUIRE([gl_LIMITS_H]) - LIMITS_H='limits.h' - AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"]) + GL_GENERATE_LIMITS_H=true ]) diff --git a/m4/link.m4 b/m4/link.m4 index 55a8a8d13..154b9d02b 100644 --- a/m4/link.m4 +++ b/m4/link.m4 @@ -1,5 +1,5 @@ # link.m4 serial 11 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/localcharset.m4 b/m4/localcharset.m4 index 04389fcbd..f5dbbd4f3 100644 --- a/m4/localcharset.m4 +++ b/m4/localcharset.m4 @@ -1,5 +1,5 @@ # localcharset.m4 serial 8 -dnl Copyright (C) 2002, 2004, 2006, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2004, 2006, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/locale-fr.m4 b/m4/locale-fr.m4 index b61df7ec9..3753891f3 100644 --- a/m4/locale-fr.m4 +++ b/m4/locale-fr.m4 @@ -1,5 +1,5 @@ # locale-fr.m4 serial 20 -dnl Copyright (C) 2003, 2005-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/locale-ja.m4 b/m4/locale-ja.m4 index cd94288cc..73a5d1aeb 100644 --- a/m4/locale-ja.m4 +++ b/m4/locale-ja.m4 @@ -1,5 +1,5 @@ # locale-ja.m4 serial 15 -dnl Copyright (C) 2003, 2005-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/locale-zh.m4 b/m4/locale-zh.m4 index 1228be828..c997971fa 100644 --- a/m4/locale-zh.m4 +++ b/m4/locale-zh.m4 @@ -1,5 +1,5 @@ # locale-zh.m4 serial 15 -dnl Copyright (C) 2003, 2005-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 index 444a38178..ca5d0d0fd 100644 --- a/m4/locale_h.m4 +++ b/m4/locale_h.m4 @@ -1,5 +1,5 @@ # locale_h.m4 serial 28 -dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/localeconv.m4 b/m4/localeconv.m4 index e29c7c329..09c1a1ac4 100644 --- a/m4/localeconv.m4 +++ b/m4/localeconv.m4 @@ -1,5 +1,5 @@ # localeconv.m4 serial 1 -dnl Copyright (C) 2012-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2012-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/lock.m4 b/m4/lock.m4 new file mode 100644 index 000000000..9da8465eb --- /dev/null +++ b/m4/lock.m4 @@ -0,0 +1,37 @@ +# lock.m4 serial 10 (gettext-0.18) +dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_LOCK], +[ + AC_REQUIRE([gl_THREADLIB]) + if test "$gl_threads_api" = posix; then + # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + AC_CHECK_TYPE([pthread_rwlock_t], + [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], + [Define if the POSIX multithreading library has read/write locks.])], + [], + [#include ]) + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + AC_TRY_COMPILE([#include ], + [#if __FreeBSD__ == 4 +error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#else +int x = (int)PTHREAD_MUTEX_RECURSIVE; +return !x; +#endif], + [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], + [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) + fi + gl_PREREQ_LOCK +]) + +# Prerequisites of lib/lock.c. +AC_DEFUN([gl_PREREQ_LOCK], [ + AC_REQUIRE([AC_C_INLINE]) +]) diff --git a/m4/log.m4 b/m4/log.m4 index 2c1683c9a..eedb871cb 100644 --- a/m4/log.m4 +++ b/m4/log.m4 @@ -1,5 +1,5 @@ # log.m4 serial 11 -dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/log1p.m4 b/m4/log1p.m4 index a1cf0f0de..7536eaf4c 100644 --- a/m4/log1p.m4 +++ b/m4/log1p.m4 @@ -1,5 +1,5 @@ # log1p.m4 serial 8 -dnl Copyright (C) 2012-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2012-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/longlong.m4 b/m4/longlong.m4 new file mode 100644 index 000000000..cca3c1a90 --- /dev/null +++ b/m4/longlong.m4 @@ -0,0 +1,106 @@ +# longlong.m4 serial 14 +dnl Copyright (C) 1999-2007, 2009-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_LONG_LONG_INT if 'long long int' works. +# This fixes a bug in Autoconf 2.61, but can be removed once we +# assume 2.62 everywhere. + +# Note: If the type 'long long int' exists but is only 32 bits large +# (as on some very old compilers), HAVE_LONG_LONG_INT will not be +# defined. In this case you can treat 'long long int' like 'long int'. + +AC_DEFUN([AC_TYPE_LONG_LONG_INT], +[ + AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], + [AC_LINK_IFELSE( + [_AC_TYPE_LONG_LONG_SNIPPET], + [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. + dnl If cross compiling, assume the bug isn't important, since + dnl nobody cross compiles for this platform as far as we know. + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[@%:@include + @%:@ifndef LLONG_MAX + @%:@ define HALF \ + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) + @%:@ define LLONG_MAX (HALF - 1 + HALF) + @%:@endif]], + [[long long int n = 1; + int i; + for (i = 0; ; i++) + { + long long int m = n << i; + if (m >> i != n) + return 1; + if (LLONG_MAX / 2 < m) + break; + } + return 0;]])], + [ac_cv_type_long_long_int=yes], + [ac_cv_type_long_long_int=no], + [ac_cv_type_long_long_int=yes])], + [ac_cv_type_long_long_int=no])]) + if test $ac_cv_type_long_long_int = yes; then + AC_DEFINE([HAVE_LONG_LONG_INT], [1], + [Define to 1 if the system has the type `long long int'.]) + fi +]) + +# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. +# This fixes a bug in Autoconf 2.61, but can be removed once we +# assume 2.62 everywhere. + +# Note: If the type 'unsigned long long int' exists but is only 32 bits +# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT +# will not be defined. In this case you can treat 'unsigned long long int' +# like 'unsigned long int'. + +AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], +[ + AC_CACHE_CHECK([for unsigned long long int], + [ac_cv_type_unsigned_long_long_int], + [AC_LINK_IFELSE( + [_AC_TYPE_LONG_LONG_SNIPPET], + [ac_cv_type_unsigned_long_long_int=yes], + [ac_cv_type_unsigned_long_long_int=no])]) + if test $ac_cv_type_unsigned_long_long_int = yes; then + AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], + [Define to 1 if the system has the type `unsigned long long int'.]) + fi +]) + +# Expands to a C program that can be used to test for simultaneous support +# of 'long long' and 'unsigned long long'. We don't want to say that +# 'long long' is available if 'unsigned long long' is not, or vice versa, +# because too many programs rely on the symmetry between signed and unsigned +# integer types (excluding 'bool'). +AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], +[ + AC_LANG_PROGRAM( + [[/* For now, do not test the preprocessor; as of 2007 there are too many + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ + /* Test literals. */ + long long int ll = 9223372036854775807ll; + long long int nll = -9223372036854775807LL; + unsigned long long int ull = 18446744073709551615ULL; + /* Test constant expressions. */ + typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) + ? 1 : -1)]; + typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 + ? 1 : -1)]; + int i = 63;]], + [[/* Test availability of runtime routines for shift and division. */ + long long int llmax = 9223372036854775807ll; + unsigned long long int ullmax = 18446744073709551615ull; + return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) + | (llmax / ll) | (llmax % ll) + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) + | (ullmax / ull) | (ullmax % ull));]]) +]) diff --git a/m4/lstat.m4 b/m4/lstat.m4 index 62e9db29a..d987060bd 100644 --- a/m4/lstat.m4 +++ b/m4/lstat.m4 @@ -1,6 +1,6 @@ # serial 33 -# Copyright (C) 1997-2001, 2003-2021 Free Software Foundation, Inc. +# Copyright (C) 1997-2001, 2003-2022 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/m4/malloc.m4 b/m4/malloc.m4 index 972e808ab..6b76c1e64 100644 --- a/m4/malloc.m4 +++ b/m4/malloc.m4 @@ -1,5 +1,5 @@ -# malloc.m4 serial 27 -dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. +# malloc.m4 serial 28 +dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -43,8 +43,9 @@ AC_DEFUN([gl_FUNC_MALLOC_GNU], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) - if test $REPLACE_MALLOC = 0; then - _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC=1]) + REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX" + if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then + _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1]) fi ]) @@ -56,7 +57,7 @@ AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) - test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC=1 + test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1 ]) # Test whether malloc, realloc, calloc refuse to create objects @@ -109,7 +110,7 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX], AC_DEFINE([HAVE_MALLOC_POSIX], [1], [Define if malloc, realloc, and calloc set errno on allocation failure.]) else - REPLACE_MALLOC=1 + REPLACE_MALLOC_FOR_MALLOC_POSIX=1 fi ]) diff --git a/m4/malloca.m4 b/m4/malloca.m4 index 06ed2c6b7..77eb96a09 100644 --- a/m4/malloca.m4 +++ b/m4/malloca.m4 @@ -1,5 +1,5 @@ # malloca.m4 serial 2 -dnl Copyright (C) 2003-2004, 2006-2007, 2009-2021 Free Software Foundation, +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/math_h.m4 b/m4/math_h.m4 index b3a10c3fb..a08526a7a 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,5 +1,5 @@ # math_h.m4 serial 125 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mathfunc.m4 b/m4/mathfunc.m4 index 92b374baa..34f5e76c4 100644 --- a/m4/mathfunc.m4 +++ b/m4/mathfunc.m4 @@ -1,5 +1,5 @@ # mathfunc.m4 serial 12 -dnl Copyright (C) 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 index 1d4e73d72..ec8716b59 100644 --- a/m4/mbrtowc.m4 +++ b/m4/mbrtowc.m4 @@ -1,5 +1,5 @@ # mbrtowc.m4 serial 38 -*- coding: utf-8 -*- -dnl Copyright (C) 2001-2002, 2004-2005, 2008-2021 Free Software Foundation, +dnl Copyright (C) 2001-2002, 2004-2005, 2008-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/mbsinit.m4 b/m4/mbsinit.m4 index dc6e10d7f..ebd2d4ffb 100644 --- a/m4/mbsinit.m4 +++ b/m4/mbsinit.m4 @@ -1,5 +1,5 @@ # mbsinit.m4 serial 9 -dnl Copyright (C) 2008, 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008, 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mbstate_t.m4 b/m4/mbstate_t.m4 index e7fe3580d..a6eba1bc1 100644 --- a/m4/mbstate_t.m4 +++ b/m4/mbstate_t.m4 @@ -1,5 +1,5 @@ # mbstate_t.m4 serial 14 -dnl Copyright (C) 2000-2002, 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2000-2002, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mbtowc.m4 b/m4/mbtowc.m4 index 7fc74c945..2827e8335 100644 --- a/m4/mbtowc.m4 +++ b/m4/mbtowc.m4 @@ -1,5 +1,5 @@ # mbtowc.m4 serial 3 -dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/memchr.m4 b/m4/memchr.m4 index ca08192a6..c7489d871 100644 --- a/m4/memchr.m4 +++ b/m4/memchr.m4 @@ -1,5 +1,5 @@ # memchr.m4 serial 18 -dnl Copyright (C) 2002-2004, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4 index f9d9ec8f3..1107eb4a4 100644 --- a/m4/mempcpy.m4 +++ b/m4/mempcpy.m4 @@ -1,5 +1,5 @@ # mempcpy.m4 serial 12 -dnl Copyright (C) 2003-2004, 2006-2007, 2009-2021 Free Software Foundation, +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/minmax.m4 b/m4/minmax.m4 index e21a6879a..b97673979 100644 --- a/m4/minmax.m4 +++ b/m4/minmax.m4 @@ -1,5 +1,5 @@ # minmax.m4 serial 4 -dnl Copyright (C) 2005, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mkdir.m4 b/m4/mkdir.m4 index 031fd291b..8b78ce960 100644 --- a/m4/mkdir.m4 +++ b/m4/mkdir.m4 @@ -1,6 +1,6 @@ # serial 17 -# Copyright (C) 2001, 2003-2004, 2006, 2008-2021 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003-2004, 2006, 2008-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/mkostemp.m4 b/m4/mkostemp.m4 index 46534d48e..2176f3729 100644 --- a/m4/mkostemp.m4 +++ b/m4/mkostemp.m4 @@ -1,5 +1,5 @@ # mkostemp.m4 serial 2 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 721189af5..431b17dcb 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,5 +1,5 @@ -# serial 36 -dnl Copyright (C) 2002-2003, 2005-2007, 2009-2021 Free Software Foundation, +# serial 37 +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -82,7 +82,8 @@ spring_forward_gap () instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ - putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); + if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0) + return -1; tm.tm_year = 98; tm.tm_mon = 3; @@ -170,7 +171,8 @@ year_2050_test () instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ - putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); + if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0) + return -1; t = mktime (&tm); @@ -181,6 +183,25 @@ year_2050_test () || (0 < t && answer - 120 <= t && t <= answer + 120)); } +static int +indiana_test () +{ + if (putenv ("TZ=America/Indiana/Indianapolis") != 0) + return -1; + struct tm tm; + tm.tm_year = 1986 - 1900; tm.tm_mon = 4 - 1; tm.tm_mday = 28; + tm.tm_hour = 16; tm.tm_min = 24; tm.tm_sec = 50; tm.tm_isdst = 0; + time_t std = mktime (&tm); + if (! (std == 515107490 || std == 515107503)) + return 1; + + /* This platform supports TZDB, either without or with leap seconds. + Return true if GNU Bug#48085 is absent. */ + tm.tm_isdst = 1; + time_t dst = mktime (&tm); + return std - dst == 60 * 60; +} + int main () { @@ -236,7 +257,7 @@ main () result |= 16; if (! spring_forward_gap ()) result |= 32; - if (! year_2050_test ()) + if (! year_2050_test () || ! indiana_test ()) result |= 64; return result; }]])], diff --git a/m4/mmap-anon.m4 b/m4/mmap-anon.m4 index e47aa2d2f..a4580ff94 100644 --- a/m4/mmap-anon.m4 +++ b/m4/mmap-anon.m4 @@ -1,5 +1,5 @@ # mmap-anon.m4 serial 12 -dnl Copyright (C) 2005, 2007, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2007, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mode_t.m4 b/m4/mode_t.m4 index 3bd4b89fe..e08d27a74 100644 --- a/m4/mode_t.m4 +++ b/m4/mode_t.m4 @@ -1,5 +1,5 @@ # mode_t.m4 serial 2 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/msvc-inval.m4 b/m4/msvc-inval.m4 index 3ba5b4e98..b32cf6eba 100644 --- a/m4/msvc-inval.m4 +++ b/m4/msvc-inval.m4 @@ -1,5 +1,5 @@ # msvc-inval.m4 serial 1 -dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/msvc-nothrow.m4 b/m4/msvc-nothrow.m4 index aae25ce7c..16ceb1f15 100644 --- a/m4/msvc-nothrow.m4 +++ b/m4/msvc-nothrow.m4 @@ -1,5 +1,5 @@ # msvc-nothrow.m4 serial 1 -dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/multiarch.m4 b/m4/multiarch.m4 index f1678d9f6..5d942765d 100644 --- a/m4/multiarch.m4 +++ b/m4/multiarch.m4 @@ -1,5 +1,5 @@ # multiarch.m4 serial 9 -dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/netdb_h.m4 b/m4/netdb_h.m4 index eb7c3b8b5..d6a9d709c 100644 --- a/m4/netdb_h.m4 +++ b/m4/netdb_h.m4 @@ -1,5 +1,5 @@ # netdb_h.m4 serial 15 -dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/netinet_in_h.m4 b/m4/netinet_in_h.m4 index c55559643..de26fe859 100644 --- a/m4/netinet_in_h.m4 +++ b/m4/netinet_in_h.m4 @@ -1,5 +1,5 @@ -# netinet_in_h.m4 serial 5 -dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. +# netinet_in_h.m4 serial 6 +dnl Copyright (C) 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -14,9 +14,9 @@ AC_DEFUN([gl_HEADER_NETINET_IN], [gl_cv_header_netinet_in_h_selfcontained=no]) ]) if test $gl_cv_header_netinet_in_h_selfcontained = yes; then - NETINET_IN_H='' + GL_GENERATE_NETINET_IN_H=false else - NETINET_IN_H='netinet/in.h' + GL_GENERATE_NETINET_IN_H=true AC_CHECK_HEADERS([netinet/in.h]) gl_CHECK_NEXT_HEADERS([netinet/in.h]) if test $ac_cv_header_netinet_in_h = yes; then @@ -26,6 +26,4 @@ AC_DEFUN([gl_HEADER_NETINET_IN], fi AC_SUBST([HAVE_NETINET_IN_H]) fi - AC_SUBST([NETINET_IN_H]) - AM_CONDITIONAL([GL_GENERATE_NETINET_IN_H], [test -n "$NETINET_IN_H"]) ]) diff --git a/m4/nl_langinfo.m4 b/m4/nl_langinfo.m4 index 6ad32c807..d20a09cf8 100644 --- a/m4/nl_langinfo.m4 +++ b/m4/nl_langinfo.m4 @@ -1,5 +1,5 @@ # nl_langinfo.m4 serial 8 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/nls.m4 b/m4/nls.m4 new file mode 100644 index 000000000..003704c4b --- /dev/null +++ b/m4/nls.m4 @@ -0,0 +1,32 @@ +# nls.m4 serial 5 (gettext-0.18) +dnl Copyright (C) 1995-2003, 2005-2006, 2008-2010 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_PREREQ([2.50]) + +AC_DEFUN([AM_NLS], +[ + AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE([nls], + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT([$USE_NLS]) + AC_SUBST([USE_NLS]) +]) diff --git a/m4/nocrash.m4 b/m4/nocrash.m4 index 27412cd2e..91f00c1bc 100644 --- a/m4/nocrash.m4 +++ b/m4/nocrash.m4 @@ -1,5 +1,5 @@ # nocrash.m4 serial 5 -dnl Copyright (C) 2005, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/nproc.m4 b/m4/nproc.m4 index 887c66bee..5c220ae2c 100644 --- a/m4/nproc.m4 +++ b/m4/nproc.m4 @@ -1,5 +1,5 @@ # nproc.m4 serial 5 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/nstrftime.m4 b/m4/nstrftime.m4 index b510554b9..0f613048e 100644 --- a/m4/nstrftime.m4 +++ b/m4/nstrftime.m4 @@ -1,6 +1,6 @@ # serial 37 -# Copyright (C) 1996-1997, 1999-2007, 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-1997, 1999-2007, 2009-2022 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/m4/off_t.m4 b/m4/off_t.m4 index bdec43c80..0890adafc 100644 --- a/m4/off_t.m4 +++ b/m4/off_t.m4 @@ -1,5 +1,5 @@ # off_t.m4 serial 1 -dnl Copyright (C) 2012-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2012-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/open-cloexec.m4 b/m4/open-cloexec.m4 index 542a90f42..16cd5ec4c 100644 --- a/m4/open-cloexec.m4 +++ b/m4/open-cloexec.m4 @@ -1,6 +1,6 @@ # Test whether O_CLOEXEC is defined. -dnl Copyright 2017-2021 Free Software Foundation, Inc. +dnl Copyright 2017-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/open-slash.m4 b/m4/open-slash.m4 index e619039e8..4fbf491a7 100644 --- a/m4/open-slash.m4 +++ b/m4/open-slash.m4 @@ -1,5 +1,5 @@ # open-slash.m4 serial 2 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/open.m4 b/m4/open.m4 index c63438650..f82fd6cac 100644 --- a/m4/open.m4 +++ b/m4/open.m4 @@ -1,5 +1,5 @@ # open.m4 serial 15 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/pathmax.m4 b/m4/pathmax.m4 index e67c65665..44add9905 100644 --- a/m4/pathmax.m4 +++ b/m4/pathmax.m4 @@ -1,5 +1,5 @@ # pathmax.m4 serial 11 -dnl Copyright (C) 2002-2003, 2005-2006, 2009-2021 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2005-2006, 2009-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/pid_t.m4 b/m4/pid_t.m4 index b7650a10f..cb26f3612 100644 --- a/m4/pid_t.m4 +++ b/m4/pid_t.m4 @@ -1,5 +1,5 @@ # pid_t.m4 serial 4 -dnl Copyright (C) 2020-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2020-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/pipe.m4 b/m4/pipe.m4 index 89d666d2a..62871c6d3 100644 --- a/m4/pipe.m4 +++ b/m4/pipe.m4 @@ -1,5 +1,5 @@ # pipe.m4 serial 2 -dnl Copyright (C) 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/pipe2.m4 b/m4/pipe2.m4 index 43d547cb4..b75224782 100644 --- a/m4/pipe2.m4 +++ b/m4/pipe2.m4 @@ -1,5 +1,5 @@ # pipe2.m4 serial 2 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/po.m4 b/m4/po.m4 new file mode 100644 index 000000000..47f36a41a --- /dev/null +++ b/m4/po.m4 @@ -0,0 +1,449 @@ +# po.m4 serial 17 (gettext-0.18) +dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_PREREQ([2.50]) + +dnl Checks for all prerequisites of the po subdirectory. +AC_DEFUN([AM_PO_SUBDIRS], +[ + AC_REQUIRE([AC_PROG_MAKE_SET])dnl + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake + AC_REQUIRE([AM_NLS])dnl + + dnl Release version of the gettext macros. This is used to ensure that + dnl the gettext macros and po/Makefile.in.in are in sync. + AC_SUBST([GETTEXT_MACRO_VERSION], [0.18]) + + dnl Perform the following tests also if --disable-nls has been given, + dnl because they are needed for "make dist" to work. + + dnl Search for GNU msgfmt in the PATH. + dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. + dnl The second test excludes FreeBSD msgfmt. + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) + + dnl Test whether it is GNU msgfmt >= 0.15. +changequote(,)dnl + case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; + *) MSGFMT_015=$MSGFMT ;; + esac +changequote([,])dnl + AC_SUBST([MSGFMT_015]) +changequote(,)dnl + case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; + *) GMSGFMT_015=$GMSGFMT ;; + esac +changequote([,])dnl + AC_SUBST([GMSGFMT_015]) + + dnl Search for GNU xgettext 0.12 or newer in the PATH. + dnl The first test excludes Solaris xgettext and early GNU xgettext versions. + dnl The second test excludes FreeBSD xgettext. + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + + dnl Test whether it is GNU xgettext >= 0.15. +changequote(,)dnl + case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; + *) XGETTEXT_015=$XGETTEXT ;; + esac +changequote([,])dnl + AC_SUBST([XGETTEXT_015]) + + dnl Search for GNU msgmerge 0.11 or newer in the PATH. + AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, + [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) + + dnl Installation directories. + dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we + dnl have to define it here, so that it can be used in po/Makefile. + test -n "$localedir" || localedir='${datadir}/locale' + AC_SUBST([localedir]) + + dnl Support for AM_XGETTEXT_OPTION. + test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= + AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) + + AC_CONFIG_COMMANDS([po-directories], [[ + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + # Treat a directory as a PO directory if and only if it has a + # POTFILES.in file. This allows packages to have multiple PO + # directories under different names or in different locations. + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + # Compute POFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) + # Compute UPDATEPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) + # Compute DUMMYPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) + # Compute GMOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + UPDATEPOFILES= + DUMMYPOFILES= + GMOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done]], + [# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it + # from automake < 1.5. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + ]) +]) + +dnl Postprocesses a Makefile in a directory containing PO files. +AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], +[ + # When this code is run, in config.status, two variables have already been + # set: + # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, + # - LINGUAS is the value of the environment variable LINGUAS at configure + # time. + +changequote(,)dnl + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + # Find a way to echo strings without interpreting backslash. + if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='echo' + else + if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='printf %s\n' + else + echo_func () { + cat < "$ac_file.tmp" + if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` + cat >> "$ac_file.tmp" < /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` + cat >> "$ac_file.tmp" <> "$ac_file.tmp" <]]) + if test $ac_cv_func_posix_spawn = yes; then + m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR], + [dnl Module 'posix_spawn_file_actions_addchdir' is present. + AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir_np]) + if test $ac_cv_func_posix_spawn_file_actions_addchdir_np = no; then + dnl In order to implement the posix_spawn_file_actions_addchdir + dnl function, we need to replace the entire posix_spawn facility. + REPLACE_POSIX_SPAWN=1 + fi + ]) + m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR], + [dnl Module 'posix_spawn_file_actions_addfchdir' is present. + AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir_np]) + if test $ac_cv_func_posix_spawn_file_actions_addfchdir_np = no; then + dnl In order to implement the posix_spawn_file_actions_addfchdir + dnl function, we need to replace the entire posix_spawn facility. + REPLACE_POSIX_SPAWN=1 + fi + ]) + if test $REPLACE_POSIX_SPAWN = 0; then + gl_POSIX_SPAWN_WORKS + case "$gl_cv_func_posix_spawn_works" in + *yes) ;; + *) REPLACE_POSIX_SPAWN=1 ;; + esac + fi + if test $REPLACE_POSIX_SPAWN = 0; then + gl_POSIX_SPAWN_SECURE + case "$gl_cv_func_posix_spawn_secure_exec" in + *yes) ;; + *) REPLACE_POSIX_SPAWN=1 ;; + esac + case "$gl_cv_func_posix_spawnp_secure_exec" in + *yes) ;; + *) REPLACE_POSIX_SPAWN=1 ;; + esac + fi + if test $REPLACE_POSIX_SPAWN = 0; then + dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDULER + dnl evaluates to nonzero. + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedpolicy]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedpolicy]) + AC_CACHE_CHECK([whether posix_spawnattr_setschedpolicy is supported], + [gl_cv_func_spawnattr_setschedpolicy], + [AC_EGREP_CPP([POSIX scheduling supported], [ +#include +#if POSIX_SPAWN_SETSCHEDULER + POSIX scheduling supported +#endif +], + [gl_cv_func_spawnattr_setschedpolicy=yes], + [gl_cv_func_spawnattr_setschedpolicy=no]) + ]) + dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDPARAM + dnl evaluates to nonzero. + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedparam]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedparam]) + AC_CACHE_CHECK([whether posix_spawnattr_setschedparam is supported], + [gl_cv_func_spawnattr_setschedparam], + [AC_EGREP_CPP([POSIX scheduling supported], [ +#include +#if POSIX_SPAWN_SETSCHEDPARAM + POSIX scheduling supported +#endif +], + [gl_cv_func_spawnattr_setschedparam=yes], + [gl_cv_func_spawnattr_setschedparam=no]) + ]) + fi + else + dnl The system does not have the main function. Therefore we have to + dnl provide our own implementation. This implies to define our own + dnl posix_spawn_file_actions_t and posix_spawnattr_t types. + if test $ac_cv_have_decl_posix_spawn = yes; then + dnl The system declares posix_spawn() already. This declaration uses + dnl the original posix_spawn_file_actions_t and posix_spawnattr_t types. + dnl But we need a declaration with our own posix_spawn_file_actions_t and + dnl posix_spawnattr_t types. + REPLACE_POSIX_SPAWN=1 + fi + fi + if test $ac_cv_func_posix_spawn != yes || test $REPLACE_POSIX_SPAWN = 1; then + AC_DEFINE([REPLACE_POSIX_SPAWN], [1], + [Define if gnulib uses its own posix_spawn and posix_spawnp functions.]) + fi +]) + +dnl Test whether posix_spawn actually works. +dnl posix_spawn on AIX 5.3..6.1 has two bugs: +dnl 1) When it fails to execute the program, the child process exits with +dnl exit() rather than _exit(), which causes the stdio buffers to be +dnl flushed. Reported by Rainer Tammer. +dnl 2) The posix_spawn_file_actions_addopen function does not support file +dnl names that contain a '*'. +dnl posix_spawn on AIX 5.3..6.1 has also a third bug: It does not work +dnl when POSIX threads are used. But we don't test against this bug here. +AC_DEFUN([gl_POSIX_SPAWN_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether posix_spawn works], [gl_cv_func_posix_spawn_works], + [if test $cross_compiling = no; then + AC_LINK_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +]GL_MDA_DEFINES[ + +extern char **environ; + +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +#ifndef WTERMSIG +# define WTERMSIG(x) ((x) & 0x7f) +#endif +#ifndef WIFEXITED +# define WIFEXITED(x) (WTERMSIG (x) == 0) +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(x) (((x) >> 8) & 0xff) +#endif + +#define CHILD_PROGRAM_FILENAME "/non/exist/ent" + +static int +fd_safer (int fd) +{ + if (0 <= fd && fd <= 2) + { + int f = fd_safer (dup (fd)); + int e = errno; + close (fd); + errno = e; + fd = f; + } + + return fd; +} + +int +main () +{ + char *argv[2] = { CHILD_PROGRAM_FILENAME, NULL }; + int ofd[2]; + sigset_t blocked_signals; + sigset_t fatal_signal_set; + posix_spawn_file_actions_t actions; + bool actions_allocated; + posix_spawnattr_t attrs; + bool attrs_allocated; + int err; + pid_t child; + int status; + int exitstatus; + + setvbuf (stdout, NULL, _IOFBF, 0); + puts ("This should be seen only once."); + if (pipe (ofd) < 0 || (ofd[1] = fd_safer (ofd[1])) < 0) + { + perror ("cannot create pipe"); + exit (1); + } + sigprocmask (SIG_SETMASK, NULL, &blocked_signals); + sigemptyset (&fatal_signal_set); + sigaddset (&fatal_signal_set, SIGINT); + sigaddset (&fatal_signal_set, SIGTERM); + sigaddset (&fatal_signal_set, SIGHUP); + sigaddset (&fatal_signal_set, SIGPIPE); + sigprocmask (SIG_BLOCK, &fatal_signal_set, NULL); + actions_allocated = false; + attrs_allocated = false; + if ((err = posix_spawn_file_actions_init (&actions)) != 0 + || (actions_allocated = true, + (err = posix_spawn_file_actions_adddup2 (&actions, ofd[0], STDIN_FILENO)) != 0 + || (err = posix_spawn_file_actions_addclose (&actions, ofd[0])) != 0 + || (err = posix_spawn_file_actions_addclose (&actions, ofd[1])) != 0 + || (err = posix_spawnattr_init (&attrs)) != 0 + || (attrs_allocated = true, + (err = posix_spawnattr_setsigmask (&attrs, &blocked_signals)) != 0 + || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0) + || (err = posix_spawnp (&child, CHILD_PROGRAM_FILENAME, &actions, &attrs, argv, environ)) != 0)) + { + if (actions_allocated) + posix_spawn_file_actions_destroy (&actions); + if (attrs_allocated) + posix_spawnattr_destroy (&attrs); + sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL); + if (err == ENOENT) + return 0; + else + { + errno = err; + perror ("subprocess failed"); + exit (1); + } + } + posix_spawn_file_actions_destroy (&actions); + posix_spawnattr_destroy (&attrs); + sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL); + close (ofd[0]); + close (ofd[1]); + status = 0; + while (waitpid (child, &status, 0) != child) + ; + if (!WIFEXITED (status)) + { + fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status); + exit (1); + } + exitstatus = WEXITSTATUS (status); + if (exitstatus != 127) + { + fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus); + exit (1); + } + return 0; +} +]])], + [if test -s conftest$ac_exeext \ + && ./conftest$ac_exeext > conftest.out \ + && echo 'This should be seen only once.' > conftest.ok \ + && cmp conftest.out conftest.ok >/dev/null 2>&1; then + gl_cv_func_posix_spawn_works=yes + else + gl_cv_func_posix_spawn_works=no + fi], + [gl_cv_func_posix_spawn_works=no]) + if test $gl_cv_func_posix_spawn_works = yes; then + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +/* Test whether posix_spawn_file_actions_addopen supports filename arguments + that contain special characters such as '*'. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +]GL_MDA_DEFINES[ + +extern char **environ; + +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +#ifndef WTERMSIG +# define WTERMSIG(x) ((x) & 0x7f) +#endif +#ifndef WIFEXITED +# define WIFEXITED(x) (WTERMSIG (x) == 0) +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(x) (((x) >> 8) & 0xff) +#endif + +#define CHILD_PROGRAM_FILENAME "conftest" +#define DATA_FILENAME "conftest%=*#?" + +static int +parent_main (void) +{ + FILE *fp; + char *argv[3] = { CHILD_PROGRAM_FILENAME, "-child", NULL }; + posix_spawn_file_actions_t actions; + bool actions_allocated; + int err; + pid_t child; + int status; + int exitstatus; + + /* Create a data file with specific contents. */ + fp = fopen (DATA_FILENAME, "wb"); + if (fp == NULL) + { + perror ("cannot create data file"); + return 1; + } + fwrite ("Halle Potta", 1, 11, fp); + if (fflush (fp) || fclose (fp)) + { + perror ("cannot prepare data file"); + return 2; + } + + /* Avoid reading from our stdin, as it could block. */ + freopen ("/dev/null", "rb", stdin); + + /* Test whether posix_spawn_file_actions_addopen with this file name + actually works, but spawning a child that reads from this file. */ + actions_allocated = false; + if ((err = posix_spawn_file_actions_init (&actions)) != 0 + || (actions_allocated = true, + (err = posix_spawn_file_actions_addopen (&actions, STDIN_FILENO, DATA_FILENAME, O_RDONLY, 0600)) != 0 + || (err = posix_spawn (&child, CHILD_PROGRAM_FILENAME, &actions, NULL, argv, environ)) != 0)) + { + if (actions_allocated) + posix_spawn_file_actions_destroy (&actions); + errno = err; + perror ("subprocess failed"); + return 3; + } + posix_spawn_file_actions_destroy (&actions); + status = 0; + while (waitpid (child, &status, 0) != child) + ; + if (!WIFEXITED (status)) + { + fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status); + return 4; + } + exitstatus = WEXITSTATUS (status); + if (exitstatus != 0) + { + fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus); + return 5; + } + return 0; +} + +static int +child_main (void) +{ + char buf[1024]; + + /* See if reading from STDIN_FILENO yields the expected contents. */ + if (fread (buf, 1, sizeof (buf), stdin) == 11 + && memcmp (buf, "Halle Potta", 11) == 0) + return 0; + else + return 8; +} + +static void +cleanup_then_die (int sig) +{ + /* Clean up data file. */ + unlink (DATA_FILENAME); + + /* Re-raise the signal and die from it. */ + signal (sig, SIG_DFL); + raise (sig); +} + +int +main (int argc, char *argv[]) +{ + int exitstatus; + + if (!(argc > 1 && strcmp (argv[1], "-child") == 0)) + { + /* This is the parent process. */ + signal (SIGINT, cleanup_then_die); + signal (SIGTERM, cleanup_then_die); + #ifdef SIGHUP + signal (SIGHUP, cleanup_then_die); + #endif + + exitstatus = parent_main (); + } + else + { + /* This is the child process. */ + + exitstatus = child_main (); + } + unlink (DATA_FILENAME); + return exitstatus; +} +]])], + [], + [gl_cv_func_posix_spawn_works=no]) + fi + else + case "$host_os" in + aix*) gl_cv_func_posix_spawn_works="guessing no";; + *) gl_cv_func_posix_spawn_works="guessing yes";; + esac + fi + ]) +]) + +dnl Test whether posix_spawn and posix_spawnp are secure. +AC_DEFUN([gl_POSIX_SPAWN_SECURE], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + dnl On many platforms, posix_spawn or posix_spawnp allow executing a + dnl script without a '#!' marker as a shell script. This is unsecure. + AC_CACHE_CHECK([whether posix_spawn rejects scripts without shebang], + [gl_cv_func_posix_spawn_secure_exec], + [echo ':' > conftest.scr + chmod a+x conftest.scr + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + #include + #include + #include + int + main () + { + const char *prog_path = "./conftest.scr"; + const char *prog_argv[2] = { prog_path, NULL }; + const char *environment[2] = { "PATH=.", NULL }; + pid_t child; + int status; + int err = posix_spawn (&child, prog_path, NULL, NULL, + (char **) prog_argv, (char **) environment); + if (err == ENOEXEC) + return 0; + if (err != 0) + return 1; + status = 0; + while (waitpid (child, &status, 0) != child) + ; + if (!WIFEXITED (status)) + return 2; + if (WEXITSTATUS (status) != 127) + return 3; + return 0; + } + ]])], + [gl_cv_func_posix_spawn_secure_exec=yes], + [gl_cv_func_posix_spawn_secure_exec=no], + [case "$host_os" in + # Guess no on GNU/Hurd. + gnu*) + gl_cv_func_posix_spawn_secure_exec="guessing no" ;; + # Guess yes on all other platforms. + *) + gl_cv_func_posix_spawn_secure_exec="guessing yes" ;; + esac + ]) + rm -f conftest.scr + ]) + AC_CACHE_CHECK([whether posix_spawnp rejects scripts without shebang], + [gl_cv_func_posix_spawnp_secure_exec], + [echo ':' > conftest.scr + chmod a+x conftest.scr + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + #include + #include + #include + int + main () + { + const char *prog_path = "./conftest.scr"; + const char *prog_argv[2] = { prog_path, NULL }; + const char *environment[2] = { "PATH=.", NULL }; + pid_t child; + int status; + int err = posix_spawnp (&child, prog_path, NULL, NULL, + (char **) prog_argv, (char **) environment); + if (err == ENOEXEC) + return 0; + if (err != 0) + return 1; + status = 0; + while (waitpid (child, &status, 0) != child) + ; + if (!WIFEXITED (status)) + return 2; + if (WEXITSTATUS (status) != 127) + return 3; + return 0; + } + ]])], + [gl_cv_func_posix_spawnp_secure_exec=yes], + [gl_cv_func_posix_spawnp_secure_exec=no], + [case "$host_os" in + # Guess yes on glibc systems (glibc >= 2.15 actually) except GNU/Hurd, + # musl libc, NetBSD. + *-gnu* | *-musl* | netbsd*) + gl_cv_func_posix_spawnp_secure_exec="guessing yes" ;; + # Guess no on GNU/Hurd, macOS, FreeBSD, OpenBSD, AIX, Solaris, Cygwin. + gnu* | darwin* | freebsd* | dragonfly* | midnightbsd* | openbsd* | \ + aix* | solaris* | cygwin*) + gl_cv_func_posix_spawnp_secure_exec="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_posix_spawnp_secure_exec="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.scr + ]) +]) + +# Prerequisites of lib/spawni.c. +AC_DEFUN([gl_PREREQ_POSIX_SPAWN_INTERNAL], +[ + AC_CHECK_HEADERS([paths.h]) + AC_CHECK_FUNCS([confstr sched_setparam sched_setscheduler setegid seteuid vfork]) +]) + +AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE], +[ + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + gl_POSIX_SPAWN + if test $REPLACE_POSIX_SPAWN = 1; then + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1 + else + dnl On musl libc, posix_spawn_file_actions_addclose succeeds even if the fd + dnl argument is negative. + AC_CACHE_CHECK([whether posix_spawn_file_actions_addclose works], + [gl_cv_func_posix_spawn_file_actions_addclose_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +int main () +{ + posix_spawn_file_actions_t actions; + if (posix_spawn_file_actions_init (&actions) != 0) + return 1; + if (posix_spawn_file_actions_addclose (&actions, -5) == 0) + return 2; + return 0; +}]])], + [gl_cv_func_posix_spawn_file_actions_addclose_works=yes], + [gl_cv_func_posix_spawn_file_actions_addclose_works=no], + [# Guess no on musl libc and Solaris, yes otherwise. + case "$host_os" in + *-musl*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; + solaris*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; + # Guess no on native Windows. + mingw*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; + *) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_posix_spawn_file_actions_addclose_works" in + *yes) ;; + *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1 ;; + esac + fi +]) + +AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2], +[ + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + gl_POSIX_SPAWN + if test $REPLACE_POSIX_SPAWN = 1; then + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1 + else + dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_adddup2 + dnl succeeds even if the fd argument is out of range. + AC_CACHE_CHECK([whether posix_spawn_file_actions_adddup2 works], + [gl_cv_func_posix_spawn_file_actions_adddup2_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +int main () +{ + posix_spawn_file_actions_t actions; + if (posix_spawn_file_actions_init (&actions) != 0) + return 1; + if (posix_spawn_file_actions_adddup2 (&actions, 10000000, 2) == 0) + return 2; + return 0; +}]])], + [gl_cv_func_posix_spawn_file_actions_adddup2_works=yes], + [gl_cv_func_posix_spawn_file_actions_adddup2_works=no], + [# Guess no on musl libc and Solaris, yes otherwise. + case "$host_os" in + *-musl*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";; + solaris*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";; + # Guess no on native Windows. + mingw*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no" ;; + *) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing yes";; + esac + ]) + ]) + case "$gl_cv_func_posix_spawn_file_actions_adddup2_works" in + *yes) ;; + *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1 ;; + esac + fi +]) + +AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN], +[ + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + gl_POSIX_SPAWN + if test $REPLACE_POSIX_SPAWN = 1; then + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1 + else + dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addopen + dnl succeeds even if the fd argument is out of range. + AC_CACHE_CHECK([whether posix_spawn_file_actions_addopen works], + [gl_cv_func_posix_spawn_file_actions_addopen_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +int main () +{ + posix_spawn_file_actions_t actions; + if (posix_spawn_file_actions_init (&actions) != 0) + return 1; + if (posix_spawn_file_actions_addopen (&actions, 10000000, "foo", 0, O_RDONLY) + == 0) + return 2; + return 0; +}]])], + [gl_cv_func_posix_spawn_file_actions_addopen_works=yes], + [gl_cv_func_posix_spawn_file_actions_addopen_works=no], + [# Guess no on musl libc and Solaris, yes otherwise. + case "$host_os" in + *-musl*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";; + solaris*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";; + # Guess no on native Windows. + mingw*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no" ;; + *) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing yes";; + esac + ]) + ]) + case "$gl_cv_func_posix_spawn_file_actions_addopen_works" in + *yes) ;; + *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1 ;; + esac + fi +]) diff --git a/m4/printf-posix.m4 b/m4/printf-posix.m4 new file mode 100644 index 000000000..1eacf95ac --- /dev/null +++ b/m4/printf-posix.m4 @@ -0,0 +1,45 @@ +# printf-posix.m4 serial 5 (gettext-0.18) +dnl Copyright (C) 2003, 2007, 2009-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether the printf() function supports POSIX/XSI format strings with +dnl positions. + +AC_DEFUN([gt_PRINTF_POSIX], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings], + gt_cv_func_printf_posix, + [ + AC_TRY_RUN([ +#include +#include +/* The string "%2$d %1$d", with dollar characters protected from the shell's + dollar expansion (possibly an autoconf bug). */ +static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; +static char buf[100]; +int main () +{ + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); +}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, + [ + AC_EGREP_CPP([notposix], [ +#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ + notposix +#endif + ], + [gt_cv_func_printf_posix="guessing no"], + [gt_cv_func_printf_posix="guessing yes"]) + ]) + ]) + case $gt_cv_func_printf_posix in + *yes) + AC_DEFINE([HAVE_POSIX_PRINTF], [1], + [Define if your printf() function supports format strings with positions.]) + ;; + esac +]) diff --git a/m4/printf.m4 b/m4/printf.m4 index 284c7c5d3..667452e34 100644 --- a/m4/printf.m4 +++ b/m4/printf.m4 @@ -1,5 +1,5 @@ # printf.m4 serial 73 -dnl Copyright (C) 2003, 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/progtest.m4 b/m4/progtest.m4 new file mode 100644 index 000000000..2d804ac99 --- /dev/null +++ b/m4/progtest.m4 @@ -0,0 +1,92 @@ +# progtest.m4 serial 6 (gettext-0.18) +dnl Copyright (C) 1996-2003, 2005, 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1996. + +AC_PREREQ([2.50]) + +# Search path for a program which passes the given test. + +dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, +dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN([AM_PATH_PROG_WITH_TEST], +[ +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "$2", so it can be a program name with args. +set dummy $2; ac_word=[$]2 +AC_MSG_CHECKING([for $ac_word]) +AC_CACHE_VAL([ac_cv_path_$1], +[case "[$]$1" in + [[\\/]]* | ?:[[\\/]]*) + ac_cv_path_$1="[$]$1" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in ifelse([$5], , $PATH, [$5]); do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD + if [$3]; then + ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" +dnl If no 4th arg is given, leave the cache variable unset, +dnl so AC_PATH_PROGS will keep looking. +ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +])dnl + ;; +esac])dnl +$1="$ac_cv_path_$1" +if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then + AC_MSG_RESULT([$][$1]) +else + AC_MSG_RESULT([no]) +fi +AC_SUBST([$1])dnl +]) diff --git a/m4/putenv.m4 b/m4/putenv.m4 index 919984d91..c7b45034e 100644 --- a/m4/putenv.m4 +++ b/m4/putenv.m4 @@ -1,5 +1,5 @@ # putenv.m4 serial 25 -dnl Copyright (C) 2002-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/raise.m4 b/m4/raise.m4 index 4bf0ca9c1..0c78d0950 100644 --- a/m4/raise.m4 +++ b/m4/raise.m4 @@ -1,5 +1,5 @@ # raise.m4 serial 4 -dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/rawmemchr.m4 b/m4/rawmemchr.m4 index 452fab18f..dae419355 100644 --- a/m4/rawmemchr.m4 +++ b/m4/rawmemchr.m4 @@ -1,5 +1,5 @@ # rawmemchr.m4 serial 3 -dnl Copyright (C) 2003, 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/read.m4 b/m4/read.m4 index c162b7cda..1c199eabb 100644 --- a/m4/read.m4 +++ b/m4/read.m4 @@ -1,5 +1,5 @@ # read.m4 serial 5 -dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/readlink.m4 b/m4/readlink.m4 index 352788c65..d1dd52122 100644 --- a/m4/readlink.m4 +++ b/m4/readlink.m4 @@ -1,5 +1,5 @@ # readlink.m4 serial 16 -dnl Copyright (C) 2003, 2007, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/realloc.m4 b/m4/realloc.m4 index 0abc4185e..86e57c259 100644 --- a/m4/realloc.m4 +++ b/m4/realloc.m4 @@ -1,5 +1,5 @@ -# realloc.m4 serial 24 -dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. +# realloc.m4 serial 26 +dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -43,8 +43,8 @@ AC_DEFUN([gl_FUNC_REALLOC_GNU], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_REALLOC_POSIX]) - if test $REPLACE_REALLOC = 0; then - _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC=1]) + if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then + _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1]) fi ])# gl_FUNC_REALLOC_GNU @@ -57,7 +57,7 @@ AC_DEFUN([gl_FUNC_REALLOC_POSIX], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) - if test $REPLACE_MALLOC = 1; then - REPLACE_REALLOC=1 + if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then + REPLACE_REALLOC_FOR_REALLOC_POSIX=1 fi ]) diff --git a/m4/regex.m4 b/m4/regex.m4 index 1c7e562f6..47342986d 100644 --- a/m4/regex.m4 +++ b/m4/regex.m4 @@ -1,6 +1,6 @@ # serial 73 -# Copyright (C) 1996-2001, 2003-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2001, 2003-2022 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/m4/rename.m4 b/m4/rename.m4 index 8a95b8aee..9f1a56543 100644 --- a/m4/rename.m4 +++ b/m4/rename.m4 @@ -1,6 +1,6 @@ # serial 33 -# Copyright (C) 2001, 2003, 2005-2006, 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005-2006, 2009-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/rmdir.m4 b/m4/rmdir.m4 index 82b9cccf2..54880278d 100644 --- a/m4/rmdir.m4 +++ b/m4/rmdir.m4 @@ -1,5 +1,5 @@ # rmdir.m4 serial 18 -dnl Copyright (C) 2002, 2005, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2005, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/round.m4 b/m4/round.m4 index 68399d363..177bfdf62 100644 --- a/m4/round.m4 +++ b/m4/round.m4 @@ -1,5 +1,5 @@ # round.m4 serial 23 -dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/safe-read.m4 b/m4/safe-read.m4 index 3cba2888d..54d47699c 100644 --- a/m4/safe-read.m4 +++ b/m4/safe-read.m4 @@ -1,5 +1,5 @@ # safe-read.m4 serial 6 -dnl Copyright (C) 2002-2003, 2005-2006, 2009-2021 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2005-2006, 2009-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/safe-write.m4 b/m4/safe-write.m4 index ef10d961b..65c791193 100644 --- a/m4/safe-write.m4 +++ b/m4/safe-write.m4 @@ -1,5 +1,5 @@ # safe-write.m4 serial 4 -dnl Copyright (C) 2002, 2005-2006, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2005-2006, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sched_h.m4 b/m4/sched_h.m4 new file mode 100644 index 000000000..ce44f7b36 --- /dev/null +++ b/m4/sched_h.m4 @@ -0,0 +1,106 @@ +# sched_h.m4 serial 15 +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN_ONCE([gl_SCHED_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_SCHED_H_DEFAULTS]) + + AC_REQUIRE([AC_CANONICAL_HOST]) + + AC_CHECK_HEADERS_ONCE([sys/cdefs.h]) + AC_CHECK_HEADERS([sched.h], [], [], + [[#if HAVE_SYS_CDEFS_H + #include + #endif + ]]) + gl_NEXT_HEADERS([sched.h]) + + if test "$ac_cv_header_sched_h" = yes; then + HAVE_SCHED_H=1 + else + HAVE_SCHED_H=0 + fi + AC_SUBST([HAVE_SCHED_H]) + + if test "$HAVE_SCHED_H" = 1; then + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0], + [[#if HAVE_SYS_CDEFS_H + #include + #endif + #include + ]]) + else + HAVE_STRUCT_SCHED_PARAM=0 + case "$host_os" in + os2*) + dnl On OS/2 kLIBC, struct sched_param is in spawn.h. + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [], + [#include ]) + ;; + vms) + dnl On OpenVMS 7.2 or newer, struct sched_param is in pthread.h. + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [], + [#include ]) + ;; + esac + fi + AC_SUBST([HAVE_STRUCT_SCHED_PARAM]) + + if test "$ac_cv_header_sys_cdefs_h" = yes; then + HAVE_SYS_CDEFS_H=1 + else + HAVE_SYS_CDEFS_H=0 + fi + AC_SUBST([HAVE_SYS_CDEFS_H]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, if it is not common + dnl enough to be declared everywhere. + gl_WARN_ON_USE_PREPARE([[#include + ]], [sched_yield]) +]) + +# gl_SCHED_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SCHED_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SCHED_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SCHED_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SCHED_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCHED_YIELD]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SCHED_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SCHED_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SCHED_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_SCHED_YIELD=1; AC_SUBST([HAVE_SCHED_YIELD]) + REPLACE_SCHED_YIELD=0; AC_SUBST([REPLACE_SCHED_YIELD]) +]) diff --git a/m4/select.m4 b/m4/select.m4 index 72c068fa4..163f8fbf7 100644 --- a/m4/select.m4 +++ b/m4/select.m4 @@ -1,5 +1,5 @@ # select.m4 serial 13 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/servent.m4 b/m4/servent.m4 index 9bc3bcd4f..c1b7d1546 100644 --- a/m4/servent.m4 +++ b/m4/servent.m4 @@ -1,5 +1,5 @@ # servent.m4 serial 4 -dnl Copyright (C) 2008, 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008, 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/setenv.m4 b/m4/setenv.m4 index f79a27850..2000039ab 100644 --- a/m4/setenv.m4 +++ b/m4/setenv.m4 @@ -1,5 +1,5 @@ # setenv.m4 serial 30 -dnl Copyright (C) 2001-2004, 2006-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2004, 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/setlocale_null.m4 b/m4/setlocale_null.m4 index 2c958ed77..09ea50eaf 100644 --- a/m4/setlocale_null.m4 +++ b/m4/setlocale_null.m4 @@ -1,5 +1,5 @@ # setlocale_null.m4 serial 5 -dnl Copyright (C) 2019-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2019-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sh-filename.m4 b/m4/sh-filename.m4 new file mode 100644 index 000000000..f5b11eaf4 --- /dev/null +++ b/m4/sh-filename.m4 @@ -0,0 +1,24 @@ +# sh-filename.m4 serial 3 +dnl Copyright (C) 2018-2022 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_SH_FILENAME], +[ + AH_VERBATIM([SH_FILENAME], +[/* File name of the Bourne shell. */ +#if (defined _WIN32 && !defined __CYGWIN__) || defined __CYGWIN__ || defined __ANDROID__ +/* Omit the directory part because + - For native Windows programs in a Cygwin environment, the Cygwin mounts + are not visible. + - For 32-bit Cygwin programs in a 64-bit Cygwin environment, the Cygwin + mounts are not visible. + - On Android, /bin/sh does not exist. It's /system/bin/sh instead. */ +# define BOURNE_SHELL "sh" +#else +# define BOURNE_SHELL "/bin/sh" +#endif]) +]) diff --git a/m4/signal_h.m4 b/m4/signal_h.m4 index 8b938809b..4c05c6274 100644 --- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 @@ -1,5 +1,5 @@ # signal_h.m4 serial 22 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/signbit.m4 b/m4/signbit.m4 index 6ec70ec44..8a4114db6 100644 --- a/m4/signbit.m4 +++ b/m4/signbit.m4 @@ -1,5 +1,5 @@ # signbit.m4 serial 20 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/size_max.m4 b/m4/size_max.m4 index 1d41ce9ab..1d6abaeaa 100644 --- a/m4/size_max.m4 +++ b/m4/size_max.m4 @@ -1,5 +1,5 @@ # size_max.m4 serial 12 -dnl Copyright (C) 2003, 2005-2006, 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2006, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/snprintf.m4 b/m4/snprintf.m4 index 852099408..7420591c9 100644 --- a/m4/snprintf.m4 +++ b/m4/snprintf.m4 @@ -1,5 +1,5 @@ # snprintf.m4 serial 7 -dnl Copyright (C) 2002-2004, 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/socketlib.m4 b/m4/socketlib.m4 index 0f8a0829c..b8bd0afa5 100644 --- a/m4/socketlib.m4 +++ b/m4/socketlib.m4 @@ -1,5 +1,5 @@ # socketlib.m4 serial 3 -dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sockets.m4 b/m4/sockets.m4 index 02b43b6e7..aa04acc3e 100644 --- a/m4/sockets.m4 +++ b/m4/sockets.m4 @@ -1,5 +1,5 @@ # sockets.m4 serial 7 -dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/socklen.m4 b/m4/socklen.m4 index eca1d1b94..1390ac41b 100644 --- a/m4/socklen.m4 +++ b/m4/socklen.m4 @@ -1,5 +1,5 @@ # socklen.m4 serial 11 -dnl Copyright (C) 2005-2007, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2005-2007, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sockpfaf.m4 b/m4/sockpfaf.m4 index 17e14c7a6..b1c4068ac 100644 --- a/m4/sockpfaf.m4 +++ b/m4/sockpfaf.m4 @@ -1,5 +1,5 @@ # sockpfaf.m4 serial 10 -dnl Copyright (C) 2004, 2006, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2004, 2006, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4 new file mode 100644 index 000000000..1b28d8036 --- /dev/null +++ b/m4/spawn_h.m4 @@ -0,0 +1,151 @@ +# spawn_h.m4 serial 21 +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN_ONCE([gl_SPAWN_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([spawn.h]) + + if test $ac_cv_header_spawn_h = yes; then + HAVE_SPAWN_H=1 + AC_CHECK_TYPES([posix_spawnattr_t], [], [HAVE_POSIX_SPAWNATTR_T=0], [[ +#include + ]]) + AC_CHECK_TYPES([posix_spawn_file_actions_t], [], + [HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0], [[ +#include + ]]) + else + HAVE_SPAWN_H=0 + HAVE_POSIX_SPAWNATTR_T=0 + HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0 + fi + AC_SUBST([HAVE_SPAWN_H]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + + AC_REQUIRE([gl_HAVE_POSIX_SPAWN]) + + AC_REQUIRE([AC_C_RESTRICT]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [posix_spawn posix_spawnp posix_spawnattr_init posix_spawnattr_destroy + posix_spawnattr_getsigdefault posix_spawnattr_setsigdefault + posix_spawnattr_getsigmask posix_spawnattr_setsigmask + posix_spawnattr_getflags posix_spawnattr_setflags + posix_spawnattr_getpgroup posix_spawnattr_setpgroup + posix_spawnattr_getschedpolicy posix_spawnattr_setschedpolicy + posix_spawnattr_getschedparam posix_spawnattr_setschedparam + posix_spawn_file_actions_init posix_spawn_file_actions_destroy + posix_spawn_file_actions_addopen posix_spawn_file_actions_addclose + posix_spawn_file_actions_adddup2 posix_spawn_file_actions_addchdir + posix_spawn_file_actions_addfchdir]) +]) + +dnl Checks whether the system has the functions posix_spawn. +dnl Sets ac_cv_func_posix_spawn and HAVE_POSIX_SPAWN. +AC_DEFUN([gl_HAVE_POSIX_SPAWN], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + + LIB_POSIX_SPAWN= + AC_SUBST([LIB_POSIX_SPAWN]) + gl_saved_libs=$LIBS + AC_SEARCH_LIBS([posix_spawn], [rt], + [test "$ac_cv_search_posix_spawn" = "none required" || + LIB_POSIX_SPAWN=$ac_cv_search_posix_spawn]) + AC_CHECK_FUNCS([posix_spawn]) + LIBS=$gl_saved_libs + + if test $ac_cv_func_posix_spawn != yes; then + HAVE_POSIX_SPAWN=0 + fi +]) + +# gl_SPAWN_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SPAWN_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SPAWN_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SPAWN_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SPAWN_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_INIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_GETFLAGS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_SETFLAGS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_GETPGROUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_SETPGROUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_GETSIGMASK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_SETSIGMASK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_SPAWNATTR_DESTROY]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SPAWN_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SPAWN_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_POSIX_SPAWN=1; AC_SUBST([HAVE_POSIX_SPAWN]) + HAVE_POSIX_SPAWNATTR_T=1; AC_SUBST([HAVE_POSIX_SPAWNATTR_T]) + HAVE_POSIX_SPAWN_FILE_ACTIONS_T=1; + AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T]) + HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1; + AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) + HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=1; + AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) + REPLACE_POSIX_SPAWN=0; AC_SUBST([REPLACE_POSIX_SPAWN]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN]) +]) diff --git a/m4/ssize_t.m4 b/m4/ssize_t.m4 index f0ed509fc..03b2b895b 100644 --- a/m4/ssize_t.m4 +++ b/m4/ssize_t.m4 @@ -1,5 +1,5 @@ # ssize_t.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2001-2003, 2006, 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2003, 2006, 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/stat-time.m4 b/m4/stat-time.m4 index df1c2a745..342857d39 100644 --- a/m4/stat-time.m4 +++ b/m4/stat-time.m4 @@ -1,6 +1,6 @@ # Checks for stat-related time functions. -# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2021 Free Software +# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2022 Free Software # Foundation, Inc. # This file is free software; the Free Software Foundation diff --git a/m4/stat.m4 b/m4/stat.m4 index 9bcdb72d6..916eb8861 100644 --- a/m4/stat.m4 +++ b/m4/stat.m4 @@ -1,6 +1,6 @@ # serial 18 -# Copyright (C) 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2009-2022 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/m4/std-gnu11.m4 b/m4/std-gnu11.m4 index 7b1a042af..5ca18607f 100644 --- a/m4/std-gnu11.m4 +++ b/m4/std-gnu11.m4 @@ -9,7 +9,7 @@ m4_version_prereq([2.70], [], [ -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2022 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 index e22d7f78c..78577cb2a 100644 --- a/m4/stdalign.m4 +++ b/m4/stdalign.m4 @@ -1,6 +1,6 @@ # Check for stdalign.h that conforms to C11. -dnl Copyright 2011-2021 Free Software Foundation, Inc. +dnl Copyright 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -49,11 +49,8 @@ AC_DEFUN([gl_STDALIGN_H], [gl_cv_header_working_stdalign_h=no])]) if test $gl_cv_header_working_stdalign_h = yes; then - STDALIGN_H='' + GL_GENERATE_STDALIGN_H=false else - STDALIGN_H='stdalign.h' + GL_GENERATE_STDALIGN_H=true fi - - AC_SUBST([STDALIGN_H]) - AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) ]) diff --git a/m4/stdbool.m4 b/m4/stdbool.m4 index 3169779d4..c67908aa8 100644 --- a/m4/stdbool.m4 +++ b/m4/stdbool.m4 @@ -1,15 +1,15 @@ # Check for stdbool.h that conforms to C99. -dnl Copyright (C) 2002-2006, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -#serial 8 +#serial 9 # Prepare for substituting if it is not supported. -AC_DEFUN([AM_STDBOOL_H], +AC_DEFUN([gl_STDBOOL_H], [ AC_REQUIRE([AC_CHECK_HEADER_STDBOOL]) AC_REQUIRE([AC_CANONICAL_HOST]) @@ -22,20 +22,18 @@ AC_DEFUN([AM_STDBOOL_H], case "$host_os" in solaris*) if test -z "$GCC"; then - STDBOOL_H='stdbool.h' + GL_GENERATE_STDBOOL_H=true else - STDBOOL_H='' + GL_GENERATE_STDBOOL_H=false fi ;; *) - STDBOOL_H='' + GL_GENERATE_STDBOOL_H=false ;; esac else - STDBOOL_H='stdbool.h' + GL_GENERATE_STDBOOL_H=true fi - AC_SUBST([STDBOOL_H]) - AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"]) if test "$ac_cv_type__Bool" = yes; then HAVE__BOOL=1 @@ -45,78 +43,76 @@ AC_DEFUN([AM_STDBOOL_H], AC_SUBST([HAVE__BOOL]) ]) -# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future. -AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H]) - -# This version of the macro is needed in autoconf <= 2.68. +m4_version_prereq([2.72], [], [ AC_DEFUN([AC_CHECK_HEADER_STDBOOL], - [AC_CACHE_CHECK([for stdbool.h that conforms to C99], + [AC_CHECK_TYPES([_Bool]) + AC_CACHE_CHECK([for stdbool.h that conforms to C99 or later], [ac_cv_header_stdbool_h], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[ - #include - - #ifdef __cplusplus - typedef bool Bool; - #else - typedef _Bool Bool; - #ifndef bool - "error: bool is not defined" - #endif - #ifndef false - "error: false is not defined" - #endif - #if false - "error: false is not 0" - #endif - #ifndef true - "error: true is not defined" - #endif - #if true != 1 - "error: true is not 1" - #endif + [[#include + + /* "true" and "false" should be usable in #if expressions and + integer constant expressions, and "bool" should be a valid + type name. + + Although C 1999 requires bool, true, and false to be macros, + C 2023 and C++ 2011 overrule that, so do not test for that. + Although C 1999 requires __bool_true_false_are_defined and + _Bool, C 2023 says they are obsolescent, so do not require + them. */ + + #if !true + #error "'true' is not true" + #endif + #if true != 1 + #error "'true' is not equal to 1" #endif + char b[true == 1 ? 1 : -1]; + char c[true]; - #ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" + #if false + #error "'false' is not false" + #endif + #if false != 0 + #error "'false' is not equal to 0" #endif + char d[false == 0 ? 1 : -1]; + + enum { e = false, f = true, g = false * true, h = true * 256 }; + + char i[(bool) 0.5 == true ? 1 : -1]; + char j[(bool) 0.0 == false ? 1 : -1]; + char k[sizeof (bool) > 0 ? 1 : -1]; + + struct sb { bool s: 1; bool t; } s; + char l[sizeof s.t > 0 ? 1 : -1]; - struct s { Bool s: 1; Bool t; bool u: 1; bool v; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - /* See body of main program for 'e'. */ - char f[(Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ - Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + bool m[h]; + char n[sizeof m == h * sizeof m[0] ? 1 : -1]; + char o[-1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html */ - Bool q = true; - Bool *pq = &q; - bool *qq = &q; + bool p = true; + bool *pp = &p; ]], [[ - bool e = &s; - *pq |= q; *pq |= ! q; - *qq |= q; *qq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq + !qq); + bool ps = &s; + *pp |= p; + *pp |= ! p; + + /* Refer to every declared value, so they cannot be + discarded as unused. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k + + !l + !m + !n + !o + !p + !pp + !ps); ]])], [ac_cv_header_stdbool_h=yes], [ac_cv_header_stdbool_h=no])]) - AC_CHECK_TYPES([_Bool]) -]) +])# AC_CHECK_HEADER_STDBOOL + +]) # m4_version_prereq 2.72 diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index 1303d2e06..abfd20303 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -1,5 +1,5 @@ -# stddef_h.m4 serial 11 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +# stddef_h.m4 serial 12 +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -14,7 +14,7 @@ AC_DEFUN_ONCE([gl_STDDEF_H], dnl Persuade OpenBSD to declare max_align_t. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - STDDEF_H= + GL_GENERATE_STDDEF_H=false dnl Test whether the type max_align_t exists and whether its alignment dnl "is as great as is supported by the implementation in all contexts". @@ -41,12 +41,12 @@ AC_DEFUN_ONCE([gl_STDDEF_H], ]) if test $gl_cv_type_max_align_t = no; then HAVE_MAX_ALIGN_T=0 - STDDEF_H=stddef.h + GL_GENERATE_STDDEF_H=true fi if test $gt_cv_c_wchar_t = no; then HAVE_WCHAR_T=0 - STDDEF_H=stddef.h + GL_GENERATE_STDDEF_H=true fi AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], @@ -58,12 +58,10 @@ AC_DEFUN_ONCE([gl_STDDEF_H], [gl_cv_decl_null_works=no])]) if test $gl_cv_decl_null_works = no; then REPLACE_NULL=1 - STDDEF_H=stddef.h + GL_GENERATE_STDDEF_H=true fi - AC_SUBST([STDDEF_H]) - AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"]) - if test -n "$STDDEF_H"; then + if $GL_GENERATE_STDDEF_H; then gl_NEXT_HEADERS([stddef.h]) fi ]) diff --git a/m4/stdint.m4 b/m4/stdint.m4 index 2eb1652d8..c3f089427 100644 --- a/m4/stdint.m4 +++ b/m4/stdint.m4 @@ -1,5 +1,5 @@ -# stdint.m4 serial 60 -dnl Copyright (C) 2001-2021 Free Software Foundation, Inc. +# stdint.m4 serial 61 +dnl Copyright (C) 2001-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -296,7 +296,7 @@ static const char *macro_values[] = HAVE_C99_STDINT_H=0 HAVE_SYS_BITYPES_H=0 HAVE_SYS_INTTYPES_H=0 - STDINT_H=stdint.h + GL_GENERATE_STDINT_H=true case "$gl_cv_header_working_stdint_h" in *yes) HAVE_C99_STDINT_H=1 @@ -341,7 +341,7 @@ int32_t i32 = INT32_C (0x7fffffff); ]])], [gl_cv_header_stdint_width=yes])]) if test "$gl_cv_header_stdint_width" = yes; then - STDINT_H= + GL_GENERATE_STDINT_H=false fi ;; *) @@ -364,8 +364,6 @@ int32_t i32 = INT32_C (0x7fffffff); AC_SUBST([HAVE_C99_STDINT_H]) AC_SUBST([HAVE_SYS_BITYPES_H]) AC_SUBST([HAVE_SYS_INTTYPES_H]) - AC_SUBST([STDINT_H]) - AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"]) ]) dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) diff --git a/m4/stdint_h.m4 b/m4/stdint_h.m4 index 18aa50a4a..b8684b61a 100644 --- a/m4/stdint_h.m4 +++ b/m4/stdint_h.m4 @@ -1,5 +1,5 @@ # stdint_h.m4 serial 9 -dnl Copyright (C) 1997-2004, 2006, 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 1997-2004, 2006, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 index e70438386..42e96071f 100644 --- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -1,5 +1,5 @@ -# stdio_h.m4 serial 56 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +# stdio_h.m4 serial 59 +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -40,41 +40,32 @@ AC_DEFUN_ONCE([gl_STDIO_H], attribute "__gnu_printf__" instead of "__printf__"]) fi - dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c" - dnl "expected source file, required through AC_LIBSOURCES, not found". It is - dnl also an optimization, to avoid performing a configure check whose result - dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING - dnl or GNULIB_NONBLOCKING redundant. + dnl This ifdef is an optimization, to avoid performing a configure check whose + dnl result is not used. But it does not make the test of + dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant. m4_ifdef([gl_NONBLOCKING_IO], [ gl_NONBLOCKING_IO if test $gl_cv_have_nonblocking != yes; then REPLACE_STDIO_READ_FUNCS=1 - AC_LIBOBJ([stdio-read]) fi ]) - dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" - dnl "expected source file, required through AC_LIBSOURCES, not found". It is - dnl also an optimization, to avoid performing a configure check whose result - dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or - dnl GNULIB_SIGPIPE redundant. + dnl This ifdef is an optimization, to avoid performing a configure check whose + dnl result is not used. But it does not make the test of + dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant. m4_ifdef([gl_SIGNAL_SIGPIPE], [ gl_SIGNAL_SIGPIPE if test $gl_cv_header_signal_h_SIGPIPE != yes; then REPLACE_STDIO_WRITE_FUNCS=1 - AC_LIBOBJ([stdio-write]) fi ]) - dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" - dnl "expected source file, required through AC_LIBSOURCES, not found". It is - dnl also an optimization, to avoid performing a configure check whose result - dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING - dnl or GNULIB_NONBLOCKING redundant. + dnl This ifdef is an optimization, to avoid performing a configure check whose + dnl result is not used. But it does not make the test of + dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant. m4_ifdef([gl_NONBLOCKING_IO], [ gl_NONBLOCKING_IO if test $gl_cv_have_nonblocking != yes; then REPLACE_STDIO_WRITE_FUNCS=1 - AC_LIBOBJ([stdio-write]) fi ]) @@ -119,6 +110,7 @@ AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE]) @@ -202,6 +194,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN]) REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) + REPLACE_FOPEN_FOR_FOPEN_GNU=0; AC_SUBST([REPLACE_FOPEN_FOR_FOPEN_GNU]) REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index 9c1d1c76c..9e2096976 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,5 +1,5 @@ -# stdlib_h.m4 serial 63 -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +# stdlib_h.m4 serial 66 +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -68,12 +68,14 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP]) @@ -90,6 +92,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH]) @@ -164,11 +167,13 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC]) - REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) + REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU]) + REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX]) REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) REPLACE_FREE=0; AC_SUBST([REPLACE_FREE]) REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE]) - REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) + REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU]) + REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX]) REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN]) @@ -178,7 +183,8 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R]) REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM]) REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) - REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) + REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU]) + REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX]) REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY]) REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) diff --git a/m4/stpcpy.m4 b/m4/stpcpy.m4 new file mode 100644 index 000000000..241e68c8c --- /dev/null +++ b/m4/stpcpy.m4 @@ -0,0 +1,25 @@ +# stpcpy.m4 serial 9 +dnl Copyright (C) 2002, 2007, 2009-2022 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STPCPY], +[ + dnl Persuade glibc to declare stpcpy(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl The stpcpy() declaration in lib/string.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + AC_CHECK_FUNCS([stpcpy]) + if test $ac_cv_func_stpcpy = no; then + HAVE_STPCPY=0 + fi +]) + +# Prerequisites of lib/stpcpy.c. +AC_DEFUN([gl_PREREQ_STPCPY], [ + : +]) diff --git a/m4/strchrnul.m4 b/m4/strchrnul.m4 new file mode 100644 index 000000000..630699b8f --- /dev/null +++ b/m4/strchrnul.m4 @@ -0,0 +1,50 @@ +# strchrnul.m4 serial 10 +dnl Copyright (C) 2003, 2007, 2009-2022 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRCHRNUL], +[ + dnl Persuade glibc to declare strchrnul(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + AC_CHECK_FUNCS([strchrnul]) + if test $ac_cv_func_strchrnul = no; then + HAVE_STRCHRNUL=0 + else + AC_CACHE_CHECK([whether strchrnul works], + [gl_cv_func_strchrnul_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include /* for strchrnul */ +]], [[const char *buf = "a"; + return strchrnul (buf, 'b') != buf + 1; + ]])], + [gl_cv_func_strchrnul_works=yes], + [gl_cv_func_strchrnul_works=no], + [dnl Cygwin 1.7.9 introduced strchrnul, but it was broken until 1.7.10 + AC_EGREP_CPP([Lucky user], + [ +#if defined __CYGWIN__ + #include + #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 9) + Lucky user + #endif +#else + Lucky user +#endif + ], + [gl_cv_func_strchrnul_works="guessing yes"], + [gl_cv_func_strchrnul_works="guessing no"]) + ]) + ]) + case "$gl_cv_func_strchrnul_works" in + *yes) ;; + *) REPLACE_STRCHRNUL=1 ;; + esac + fi +]) + +# Prerequisites of lib/strchrnul.c. +AC_DEFUN([gl_PREREQ_STRCHRNUL], [:]) diff --git a/m4/strdup.m4 b/m4/strdup.m4 index 5b6018ff2..da8899d16 100644 --- a/m4/strdup.m4 +++ b/m4/strdup.m4 @@ -1,6 +1,6 @@ # strdup.m4 serial 15 -dnl Copyright (C) 2002-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/string_h.m4 b/m4/string_h.m4 index 80d1e5875..9e09b96e1 100644 --- a/m4/string_h.m4 +++ b/m4/string_h.m4 @@ -1,11 +1,11 @@ # Configure a GNU-like replacement for . -# Copyright (C) 2007-2021 Free Software Foundation, Inc. +# Copyright (C) 2007-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 32 +# serial 34 # Written by Paul Eggert. @@ -93,6 +93,8 @@ AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_STRDUP], [1]) ]) m4_require(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS]) + dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized. + gl_STDLIB_H_REQUIRE_DEFAULTS AC_REQUIRE([gl_STRING_H_DEFAULTS]) ]) diff --git a/m4/sys_file_h.m4 b/m4/sys_file_h.m4 index bcde4d70b..61bd733ee 100644 --- a/m4/sys_file_h.m4 +++ b/m4/sys_file_h.m4 @@ -1,7 +1,7 @@ # Configure a replacement for . # serial 9 -# Copyright (C) 2008-2021 Free Software Foundation, Inc. +# Copyright (C) 2008-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_random_h.m4 b/m4/sys_random_h.m4 index 37bc31606..a5ba85c67 100644 --- a/m4/sys_random_h.m4 +++ b/m4/sys_random_h.m4 @@ -1,5 +1,5 @@ # sys_random_h.m4 serial 8 -dnl Copyright (C) 2020-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2020-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_select_h.m4 b/m4/sys_select_h.m4 index 2e7d140de..2743cd179 100644 --- a/m4/sys_select_h.m4 +++ b/m4/sys_select_h.m4 @@ -1,5 +1,5 @@ # sys_select_h.m4 serial 23 -dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 index 5676a0d21..ba3ae68e6 100644 --- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -1,5 +1,5 @@ -# sys_socket_h.m4 serial 28 -dnl Copyright (C) 2005-2021 Free Software Foundation, Inc. +# sys_socket_h.m4 serial 29 +dnl Copyright (C) 2005-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -22,6 +22,7 @@ AC_DEFUN_ONCE([gl_SYS_SOCKET_H], ;; esac + GL_GENERATE_SYS_SOCKET_H=false AC_CACHE_CHECK([whether is self-contained], [gl_cv_header_sys_socket_h_selfcontained], [ @@ -44,7 +45,7 @@ AC_DEFUN_ONCE([gl_SYS_SOCKET_H], [gl_cv_header_sys_socket_h_shut=no]) ]) if test $gl_cv_header_sys_socket_h_shut = no; then - SYS_SOCKET_H='sys/socket.h' + GL_GENERATE_SYS_SOCKET_H=true fi fi fi @@ -83,7 +84,7 @@ AC_DEFUN_ONCE([gl_SYS_SOCKET_H], fi if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then - SYS_SOCKET_H='sys/socket.h' + GL_GENERATE_SYS_SOCKET_H=true fi gl_PREREQ_SYS_H_WINSOCK2 diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 index ac91d425b..2adbfdeef 100644 --- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,5 +1,5 @@ -# sys_stat_h.m4 serial 41 -*- Autoconf -*- -dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. +# sys_stat_h.m4 serial 42 -*- Autoconf -*- +dnl Copyright (C) 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -46,7 +46,7 @@ AC_DEFUN_ONCE([gl_SYS_STAT_H], dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[#include - ]], [fchmodat fstat fstatat futimens getumask lchmod lstat + ]], [chmod fchmodat fstat fstatat futimens getumask lchmod lstat mkdirat mkfifo mkfifoat mknod mknodat stat utimensat]) AC_REQUIRE([AC_C_RESTRICT]) @@ -72,6 +72,7 @@ AC_DEFUN([gl_SYS_STAT_H_REQUIRE_DEFAULTS], [ m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS], [ gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHMOD]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHMODAT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTAT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTATAT]) @@ -112,6 +113,7 @@ AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD]) HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT]) HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT]) + REPLACE_CHMOD=0; AC_SUBST([REPLACE_CHMOD]) REPLACE_FCHMODAT=0; AC_SUBST([REPLACE_FCHMODAT]) REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT]) REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT]) diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 index c425a9639..bc5e2b136 100644 --- a/m4/sys_time_h.m4 +++ b/m4/sys_time_h.m4 @@ -1,7 +1,7 @@ # Configure a replacement for . # serial 12 -# Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_times_h.m4 b/m4/sys_times_h.m4 index 577ead66f..5d26954e9 100644 --- a/m4/sys_times_h.m4 +++ b/m4/sys_times_h.m4 @@ -1,7 +1,7 @@ # Configure a replacement for . # serial 11 -# Copyright (C) 2008-2021 Free Software Foundation, Inc. +# Copyright (C) 2008-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4 index 6dd6fee10..a5bef220c 100644 --- a/m4/sys_types_h.m4 +++ b/m4/sys_types_h.m4 @@ -1,5 +1,5 @@ # sys_types_h.m4 serial 13 -dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_uio_h.m4 b/m4/sys_uio_h.m4 index fa176e0b6..36f55eadc 100644 --- a/m4/sys_uio_h.m4 +++ b/m4/sys_uio_h.m4 @@ -1,5 +1,5 @@ # sys_uio_h.m4 serial 3 -dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/tempname.m4 b/m4/tempname.m4 index 14c796d3e..22ccec1f8 100644 --- a/m4/tempname.m4 +++ b/m4/tempname.m4 @@ -1,6 +1,6 @@ #serial 5 -# Copyright (C) 2006-2007, 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2006-2007, 2009-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 index 37b797c18..ecb4970af 100644 --- a/m4/threadlib.m4 +++ b/m4/threadlib.m4 @@ -1,5 +1,5 @@ -# threadlib.m4 serial 31 -dnl Copyright (C) 2005-2021 Free Software Foundation, Inc. +# threadlib.m4 serial 32 +dnl Copyright (C) 2005-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -84,38 +84,48 @@ AC_DEFUN([gl_WEAK_SYMBOLS], AC_REQUIRE([AC_CANONICAL_HOST]) AC_CACHE_CHECK([whether imported symbols can be declared weak], [gl_cv_have_weak], - [gl_cv_have_weak=no - dnl First, test whether the compiler accepts it syntactically. - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[extern void xyzzy (); + [case "$host_os" in + cygwin*) + dnl On Cygwin 3.2.0 with gcc 10.2, the test below would succeed, but + dnl programs that use pthread_in_use() with weak symbol references + dnl crash miserably at runtime. + gl_cv_have_weak="guessing no" + ;; + *) + gl_cv_have_weak=no + dnl First, test whether the compiler accepts it syntactically. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern void xyzzy (); #pragma weak xyzzy]], - [[xyzzy();]])], - [gl_cv_have_weak=maybe]) - if test $gl_cv_have_weak = maybe; then - dnl Second, test whether it actually works. On Cygwin 1.7.2, with - dnl gcc 4.3, symbols declared weak always evaluate to the address 0. - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ + [[xyzzy();]])], + [gl_cv_have_weak=maybe]) + if test $gl_cv_have_weak = maybe; then + dnl Second, test whether it actually works. On Cygwin 1.7.2, with + dnl gcc 4.3, symbols declared weak always evaluate to the address 0. + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include #pragma weak fputs int main () { return (fputs == NULL); }]])], - [gl_cv_have_weak=yes], - [gl_cv_have_weak=no], - [dnl When cross-compiling, assume that only ELF platforms support - dnl weak symbols. - AC_EGREP_CPP([Extensible Linking Format], - [#ifdef __ELF__ - Extensible Linking Format - #endif - ], - [gl_cv_have_weak="guessing yes"], - [gl_cv_have_weak="guessing no"]) - ]) - fi + [gl_cv_have_weak=yes], + [gl_cv_have_weak=no], + [dnl When cross-compiling, assume that only ELF platforms support + dnl weak symbols. + AC_EGREP_CPP([Extensible Linking Format], + [#ifdef __ELF__ + Extensible Linking Format + #endif + ], + [gl_cv_have_weak="guessing yes"], + [gl_cv_have_weak="guessing no"]) + ]) + fi + ;; + esac dnl But when linking statically, weak symbols don't work. case " $LDFLAGS " in *" -static "*) gl_cv_have_weak=no ;; diff --git a/m4/time_h.m4 b/m4/time_h.m4 index b57474b48..98d7b6e01 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -1,8 +1,8 @@ # Configure a more-standard replacement for . -# Copyright (C) 2000-2001, 2003-2007, 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2000-2001, 2003-2007, 2009-2022 Free Software Foundation, Inc. -# serial 18 +# serial 19 # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -133,6 +133,7 @@ AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET]) @@ -151,6 +152,7 @@ AC_DEFUN([gl_TIME_H_DEFAULTS], HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET]) + HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES]) dnl Even GNU libc does not have timezone_t yet. HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T]) dnl If another module says to replace or to not replace, do that. diff --git a/m4/time_r.m4 b/m4/time_r.m4 index 2d49b64f1..8a1ad9dad 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -1,6 +1,6 @@ dnl Reentrant time functions: localtime_r, gmtime_r. -dnl Copyright (C) 2003, 2006-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/time_rz.m4 b/m4/time_rz.m4 index c5e85dc62..4cb6a0648 100644 --- a/m4/time_rz.m4 +++ b/m4/time_rz.m4 @@ -1,6 +1,6 @@ dnl Time zone functions: tzalloc, localtime_rz, etc. -dnl Copyright (C) 2015-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2015-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/timegm.m4 b/m4/timegm.m4 index 58123beb0..f1893941f 100644 --- a/m4/timegm.m4 +++ b/m4/timegm.m4 @@ -1,5 +1,5 @@ # timegm.m4 serial 13 -dnl Copyright (C) 2003, 2007, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/times.m4 b/m4/times.m4 index fe75c31bf..cd828c6d4 100644 --- a/m4/times.m4 +++ b/m4/times.m4 @@ -1,5 +1,5 @@ # times.m4 serial 2 -dnl Copyright (C) 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/tm_gmtoff.m4 b/m4/tm_gmtoff.m4 index 2743999fb..9275bed67 100644 --- a/m4/tm_gmtoff.m4 +++ b/m4/tm_gmtoff.m4 @@ -1,5 +1,5 @@ # tm_gmtoff.m4 serial 3 -dnl Copyright (C) 2002, 2009-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/trunc.m4 b/m4/trunc.m4 index b80b91926..811256ce5 100644 --- a/m4/trunc.m4 +++ b/m4/trunc.m4 @@ -1,5 +1,5 @@ # trunc.m4 serial 15 -dnl Copyright (C) 2007, 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007, 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/tzset.m4 b/m4/tzset.m4 index 8a4f28557..2c7e17e28 100644 --- a/m4/tzset.m4 +++ b/m4/tzset.m4 @@ -1,6 +1,6 @@ # serial 16 -# Copyright (C) 2003, 2007, 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2003, 2007, 2009-2022 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/uintmax_t.m4 b/m4/uintmax_t.m4 new file mode 100644 index 000000000..03b51bcfe --- /dev/null +++ b/m4/uintmax_t.m4 @@ -0,0 +1,30 @@ +# uintmax_t.m4 serial 12 +dnl Copyright (C) 1997-2004, 2007-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +AC_PREREQ([2.13]) + +# Define uintmax_t to 'unsigned long' or 'unsigned long long' +# if it is not already defined in or . + +AC_DEFUN([gl_AC_TYPE_UINTMAX_T], +[ + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) + test $ac_cv_type_unsigned_long_long_int = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type], + [Define to unsigned long or unsigned long long + if and don't define.]) + else + AC_DEFINE([HAVE_UINTMAX_T], [1], + [Define if you have the 'uintmax_t' type in or .]) + fi +]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 0ce4ea451..4c66ccc0a 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,5 +1,5 @@ -# unistd_h.m4 serial 89 -dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. +# unistd_h.m4 serial 90 +dnl Copyright (C) 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -112,6 +112,7 @@ AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETOPT_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAGESIZE]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUSERSHELL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GROUP_MEMBER]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISATTY]) @@ -170,98 +171,100 @@ AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS], AC_DEFUN([gl_UNISTD_H_DEFAULTS], [ dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) - HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE]) - HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) - HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) - HAVE_EXECVPE=1; AC_SUBST([HAVE_EXECVPE]) - HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) - HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) - HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) - HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC]) - HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) - HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) - HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) - HAVE_GETENTROPY=1; AC_SUBST([HAVE_GETENTROPY]) - HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) - HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) - HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) - HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) - HAVE_GETPASS=1; AC_SUBST([HAVE_GETPASS]) - HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER]) - HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) - HAVE_LINK=1; AC_SUBST([HAVE_LINK]) - HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) - HAVE_PIPE=1; AC_SUBST([HAVE_PIPE]) - HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) - HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) - HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) - HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) - HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) - HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) - HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) - HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) - HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) - HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) - HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) - HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) - HAVE_DECL_EXECVPE=1; AC_SUBST([HAVE_DECL_EXECVPE]) - HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) - HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC]) - HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) - HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN]) - HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) - HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) - HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) - HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME]) - HAVE_DECL_TRUNCATE=1; AC_SUBST([HAVE_DECL_TRUNCATE]) - HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) - HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) - HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) - REPLACE_ACCESS=0; AC_SUBST([REPLACE_ACCESS]) - REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) - REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) - REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) - REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) - REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL]) - REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE]) - REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP]) - REPLACE_EXECV=0; AC_SUBST([REPLACE_EXECV]) - REPLACE_EXECVE=0; AC_SUBST([REPLACE_EXECVE]) - REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP]) - REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE]) - REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT]) - REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) - REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) - REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) - REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) - REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE]) - REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) - REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) - REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) - REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS]) - REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) - REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) - REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) - REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) - REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) - REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) - REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) - REPLACE_READ=0; AC_SUBST([REPLACE_READ]) - REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) - REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT]) - REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) - REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) - REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) - REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT]) - REPLACE_TRUNCATE=0; AC_SUBST([REPLACE_TRUNCATE]) - REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) - REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) - REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) - REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) - REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE]) - UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H]) - UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H]) + HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) + HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE]) + HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) + HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) + HAVE_EXECVPE=1; AC_SUBST([HAVE_EXECVPE]) + HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) + HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) + HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) + HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC]) + HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) + HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) + HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) + HAVE_GETENTROPY=1; AC_SUBST([HAVE_GETENTROPY]) + HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) + HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) + HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) + HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) + HAVE_GETPASS=1; AC_SUBST([HAVE_GETPASS]) + HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER]) + HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) + HAVE_LINK=1; AC_SUBST([HAVE_LINK]) + HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) + HAVE_PIPE=1; AC_SUBST([HAVE_PIPE]) + HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) + HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) + HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) + HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) + HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) + HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) + HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) + HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) + HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) + HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) + HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) + HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) + HAVE_DECL_EXECVPE=1; AC_SUBST([HAVE_DECL_EXECVPE]) + HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) + HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC]) + HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) + HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN]) + HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) + HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) + HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) + HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME]) + HAVE_DECL_TRUNCATE=1; AC_SUBST([HAVE_DECL_TRUNCATE]) + HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) + HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) + HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) + REPLACE_ACCESS=0; AC_SUBST([REPLACE_ACCESS]) + REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) + REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) + REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE]) + REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) + REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) + REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL]) + REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE]) + REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP]) + REPLACE_EXECV=0; AC_SUBST([REPLACE_EXECV]) + REPLACE_EXECVE=0; AC_SUBST([REPLACE_EXECVE]) + REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP]) + REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE]) + REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT]) + REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) + REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) + REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) + REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) + REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE]) + REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) + REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) + REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) + REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS]) + REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU]) + REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) + REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) + REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) + REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) + REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) + REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) + REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) + REPLACE_READ=0; AC_SUBST([REPLACE_READ]) + REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) + REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT]) + REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) + REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) + REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) + REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT]) + REPLACE_TRUNCATE=0; AC_SUBST([REPLACE_TRUNCATE]) + REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) + REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) + REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) + REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) + REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE]) + UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H]) + UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H]) UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) ]) diff --git a/m4/vararrays.m4 b/m4/vararrays.m4 new file mode 100644 index 000000000..28e22a49d --- /dev/null +++ b/m4/vararrays.m4 @@ -0,0 +1,72 @@ +# Check for variable-length arrays. + +# serial 6 + +# From Paul Eggert + +# Copyright (C) 2001, 2009-2022 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +m4_version_prereq([2.70], [], [ + +# AC_C_VARARRAYS +# -------------- +# Check whether the C compiler supports variable-length arrays. +AC_DEFUN([AC_C_VARARRAYS], +[ + AC_CACHE_CHECK([for variable-length arrays], + ac_cv_c_vararrays, + [AC_EGREP_CPP([defined], + [#ifdef __STDC_NO_VLA__ + defined + #endif + ], + [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* Test for VLA support. This test is partly inspired + from examples in the C standard. Use at least two VLA + functions to detect the GCC 3.4.3 bug described in: + https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html + */ + #ifdef __STDC_NO_VLA__ + syntax error; + #else + extern int n; + int B[100]; + int fvla (int m, int C[m][m]); + + int + simple (int count, int all[static count]) + { + return all[count - 1]; + } + + int + fvla (int m, int C[m][m]) + { + typedef int VLA[m][m]; + VLA x; + int D[m]; + static int (*q)[m] = &B; + int (*s)[n] = q; + return C && &x[0][0] == &D[0] && &D[0] == s[0]; + } + #endif + ]])], + [ac_cv_c_vararrays=yes], + [ac_cv_c_vararrays=no])])]) + if test "$ac_cv_c_vararrays" = yes; then + dnl This is for compatibility with Autoconf 2.61-2.69. + AC_DEFINE([HAVE_C_VARARRAYS], 1, + [Define to 1 if C supports variable-length arrays.]) + elif test "$ac_cv_c_vararrays" = no; then + AC_DEFINE([__STDC_NO_VLA__], 1, + [Define to 1 if C does not support variable-length arrays, and + if the compiler does not already define this.]) + fi +]) + +]) diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4 index 483bba969..afdece71c 100644 --- a/m4/vasnprintf.m4 +++ b/m4/vasnprintf.m4 @@ -1,5 +1,5 @@ # vasnprintf.m4 serial 38 -dnl Copyright (C) 2002-2004, 2006-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/visibility.m4 b/m4/visibility.m4 index d161bd7f7..4a212a4e5 100644 --- a/m4/visibility.m4 +++ b/m4/visibility.m4 @@ -1,5 +1,5 @@ # visibility.m4 serial 8 -dnl Copyright (C) 2005, 2008, 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2008, 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/vsnprintf.m4 b/m4/vsnprintf.m4 index 5f5375e63..02b448f3b 100644 --- a/m4/vsnprintf.m4 +++ b/m4/vsnprintf.m4 @@ -1,5 +1,5 @@ # vsnprintf.m4 serial 7 -dnl Copyright (C) 2002-2004, 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4 index 04edfe85d..d43355ab1 100644 --- a/m4/warn-on-use.m4 +++ b/m4/warn-on-use.m4 @@ -1,5 +1,5 @@ # warn-on-use.m4 serial 9 -dnl Copyright (C) 2010-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/warnings.m4 b/m4/warnings.m4 index 9e24d898e..60088f93e 100644 --- a/m4/warnings.m4 +++ b/m4/warnings.m4 @@ -1,5 +1,5 @@ # warnings.m4 serial 16 -dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4 index 818b3192e..4baba1af0 100644 --- a/m4/wchar_h.m4 +++ b/m4/wchar_h.m4 @@ -1,13 +1,13 @@ dnl A placeholder for ISO C99 , for platforms that have issues. -dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Written by Eric Blake. -# wchar_h.m4 serial 53 +# wchar_h.m4 serial 55 AC_DEFUN_ONCE([gl_WCHAR_H], [ @@ -189,6 +189,8 @@ AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WCSDUP], [1]) ]) m4_require(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS]) + dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized. + gl_STDLIB_H_REQUIRE_DEFAULTS AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) ]) diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4 index 34db10e5c..268e3e515 100644 --- a/m4/wchar_t.m4 +++ b/m4/wchar_t.m4 @@ -1,5 +1,5 @@ # wchar_t.m4 serial 4 (gettext-0.18.2) -dnl Copyright (C) 2002-2003, 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2003, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/wcrtomb.m4 b/m4/wcrtomb.m4 index cd96f1161..fee21d7ef 100644 --- a/m4/wcrtomb.m4 +++ b/m4/wcrtomb.m4 @@ -1,5 +1,5 @@ # wcrtomb.m4 serial 17 -dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/wctype_h.m4 b/m4/wctype_h.m4 index 7d7421277..702cb39cd 100644 --- a/m4/wctype_h.m4 +++ b/m4/wctype_h.m4 @@ -2,7 +2,7 @@ dnl A placeholder for ISO C99 , for platforms that lack it. -dnl Copyright (C) 2006-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/wint_t.m4 b/m4/wint_t.m4 index a49c50813..adc586614 100644 --- a/m4/wint_t.m4 +++ b/m4/wint_t.m4 @@ -1,5 +1,5 @@ # wint_t.m4 serial 11 -dnl Copyright (C) 2003, 2007-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/write.m4 b/m4/write.m4 index 84400c5f0..33b5dce60 100644 --- a/m4/write.m4 +++ b/m4/write.m4 @@ -1,5 +1,5 @@ # write.m4 serial 6 -dnl Copyright (C) 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/xsize.m4 b/m4/xsize.m4 index 64e8a4f45..0109049e0 100644 --- a/m4/xsize.m4 +++ b/m4/xsize.m4 @@ -1,5 +1,5 @@ # xsize.m4 serial 5 -dnl Copyright (C) 2003-2004, 2008-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2003-2004, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/year2038.m4 b/m4/year2038.m4 index da0f8d730..2e4427e6f 100644 --- a/m4/year2038.m4 +++ b/m4/year2038.m4 @@ -1,5 +1,5 @@ -# year2038.m4 serial 7 -dnl Copyright (C) 2017-2021 Free Software Foundation, Inc. +# year2038.m4 serial 8 +dnl Copyright (C) 2017-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -7,6 +7,12 @@ dnl with or without modifications, as long as this notice is preserved. dnl Attempt to ensure that 'time_t' can go past the year 2038 and that dnl the functions 'time', 'stat', etc. work with post-2038 timestamps. +m4_ifdef([AC_SYS_YEAR2038], [ + AC_DEFUN([gl_YEAR2038_EARLY]) + AC_DEFUN([gl_YEAR2038], [AC_SYS_YEAR2038]) + AC_DEFUN([gl_YEAR2038_BODY], [_AC_SYS_YEAR2038]) +], [ + AC_DEFUN([gl_YEAR2038_EARLY], [ AC_REQUIRE([AC_CANONICAL_HOST]) @@ -122,3 +128,5 @@ AC_DEFUN([gl_YEAR2038], [ gl_YEAR2038_BODY([require-year2038-safe]) ]) + +]) # m4_ifndef AC_SYS_YEAR2038 diff --git a/m4/zzgnulib.m4 b/m4/zzgnulib.m4 index b9533847c..fd73a201f 100644 --- a/m4/zzgnulib.m4 +++ b/m4/zzgnulib.m4 @@ -1,5 +1,5 @@ # zzgnulib.m4 serial 1 -dnl Copyright (C) 2020-2021 Free Software Foundation, Inc. +dnl Copyright (C) 2020-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/maint.mk b/maint.mk index 6a3ea9606..5745d5831 100644 --- a/maint.mk +++ b/maint.mk @@ -2,7 +2,7 @@ # This Makefile fragment tries to be general-purpose enough to be # used by many projects via the gnulib maintainer-makefile module. -## Copyright (C) 2001-2021 Free Software Foundation, Inc. +## Copyright (C) 2001-2022 Free Software Foundation, Inc. ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -64,7 +64,7 @@ VC_LIST = $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir) # You can override this variable in cfg.mk if your gnulib submodule lives # in a different location. -gnulib_dir ?= $(shell if test -d $(srcdir)/gnulib; then \ +gnulib_dir ?= $(shell if test -f $(srcdir)/gnulib/gnulib-tool; then \ echo $(srcdir)/gnulib; \ else \ echo ${GNULIB_SRCDIR}; \ @@ -473,7 +473,7 @@ sc_error_message_uppercase: @$(VC_LIST_EXCEPT) \ | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ | $(GREP) -E '"[A-Z]' \ - | $(GREP) -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' \ + | $(GREP) -vE '"FATAL|"WARNING|"Java|"C#|"PRI' \ && { echo '$(ME): found capitalized error message' 1>&2; \ exit 1; } \ || : @@ -622,9 +622,9 @@ sc_prohibit_xalloc_without_use: $(_sc_header_without_use) # Extract function names: -# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h +# perl -lne '/^(?:extern )?(?:void|char|Hash_table) \*?(\w+) *\(/ and print $1' lib/hash.h _hash_re = \ -clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning +hash_(re(set_tuning|move)|xin(itialize|sert)|in(itialize|sert)|get_(firs|nex)t|print_statistics|(delet|fre)e|lookup|clear) _hash_fn = \<($(_hash_re)) *\( _hash_struct = (struct )?\<[Hh]ash_(table|tuning)\> sc_prohibit_hash_without_use: @@ -823,7 +823,7 @@ sc_trailing_blank: # Match lines like the following, but where there is only one space # between the options and the description: # -D, --all-repeated[=delimit-method] print all duplicate lines\n -longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)? +longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*]?)? sc_two_space_separator_in_usage: @prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \ halt='help2man requires at least two spaces between an option and its description'\ @@ -1031,7 +1031,7 @@ perl_filename_lineno_text_ = \ -e ' }' prohibit_doubled_words_ = \ - the then in an on if is it but for or at and do to + the then in an on if is it but for or at and do to can # expand the regex before running the check to avoid using expensive captures prohibit_doubled_word_expanded_ = \ $(join $(prohibit_doubled_words_),$(addprefix \s+,$(prohibit_doubled_words_))) @@ -1256,6 +1256,12 @@ sc_makefile_path_separator_check: halt=$(msg) \ $(_sc_search_regexp) +sc_makefile_DISTCHECK_CONFIGURE_FLAGS: + @prohibit='^DISTCHECK_CONFIGURE_FLAGS' \ + in_vc_files='akefile|\.mk$$' \ + halt="use AM_DISTCHECK_CONFIGURE_FLAGS" \ + $(_sc_search_regexp) + # Check that 'make alpha' will not fail at the end of the process, # i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release) # and is read-only. @@ -1390,7 +1396,12 @@ gpg_key_ID ?= \ $$(cd $(srcdir) \ && git cat-file tag v$(VERSION) \ | $(gpgv) --status-fd 1 --keyring /dev/null - - 2>/dev/null \ - | $(AWK) '/^\[GNUPG:\] ERRSIG / {print $$3; exit}') + | $(AWK) '/^\[GNUPG:] ERRSIG / {print $$3; exit}') +gpg_key_email ?= \ + $$(gpg --list-key --with-colons $(gpg_key_ID) 2>/dev/null \ + | $(AWK) -F: '/^uid/ {print $$10; exit}' \ + | $(SED) -n 's/.*<\(.*\)>/\1/p') +gpg_keyring_url ?= https://savannah.gnu.org/project/release-gpgkeys.php?group=$(PACKAGE)&download=1 translation_project_ ?= coordinator@translationproject.org @@ -1421,6 +1432,10 @@ announcement: NEWS ChangeLog $(rel-files) --prev=$(PREV_VERSION) \ --curr=$(VERSION) \ --gpg-key-id=$(gpg_key_ID) \ + $$(test -n "$(gpg_key_email)" && \ + echo --gpg-key-email="$(gpg_key_email)") \ + $$(test -n "$(gpg_keyring_url)" && \ + echo --gpg-keyring-url="$(gpg_keyring_url)") \ --srcdir=$(srcdir) \ --news=$(srcdir)/NEWS \ --bootstrap-tools=$(bootstrap-tools) \ @@ -1522,7 +1537,7 @@ alpha beta stable: $(local-check) writable-files $(submodule-checks) release: $(AM_V_GEN)$(MAKE) _version - $(AM_V_GEN)$(MAKE) $(release-type) + $(AM_V_at)$(MAKE) $(release-type) # Override this in cfg.mk if you follow different procedures. release-prep-hook ?= release-prep @@ -1631,12 +1646,32 @@ refresh-po: ls $(PODIR)/*.po | $(SED) 's/\.po//;s,$(PODIR)/,,' | \ sort >> $(PODIR)/LINGUAS - # Running indent once is not idempotent, but running it twice is. +# Indentation + +indent_args ?= -ppi 1 +C_SOURCES ?= $$($(VC_LIST_EXCEPT) | grep '\.[ch]\(.in\)\?$$') INDENT_SOURCES ?= $(C_SOURCES) +exclude_file_name_regexp--indent ?= $(exclude_file_name_regexp--sc_indent) + .PHONY: indent -indent: - indent $(INDENT_SOURCES) - indent $(INDENT_SOURCES) +indent: # Running indent once is not idempotent, but running it twice is. + $(AM_V_GEN)indent $(indent_args) $(INDENT_SOURCES) && \ + indent $(indent_args) $(INDENT_SOURCES) + +sc_indent: + @if ! command -v indent > /dev/null; then \ + echo 1>&2 '$(ME): sc_indent: indent is missing'; \ + else \ + fail=0; files="$(INDENT_SOURCES)"; \ + for f in $$files; do \ + indent $(indent_args) -st $$f \ + | indent $(indent_args) -st - \ + | diff -u $$f - || fail=1; \ + done; \ + test $$fail = 1 && \ + { echo 1>&2 '$(ME): code format error, try "make indent"'; \ + exit 1; } || :; \ + fi # If you want to set UPDATE_COPYRIGHT_* environment variables, # put the assignments in this variable. @@ -1682,9 +1717,8 @@ sc_tight_scope: tight-scope.mk exit $$fail tight-scope.mk: $(ME) - @rm -f $@ $@-t @perl -ne '/^# TS-start/.../^# TS-end/ and print' $(srcdir)/$(ME) > $@-t - @chmod a=r $@-t && mv $@-t $@ + @mv $@-t $@ ifeq (a,b) # TS-start @@ -1715,8 +1749,8 @@ _gl_TS_unmarked_extern_vars ?= # a macro like this: GLOBAL(type, var_name, initializer), then you # can override this definition to automatically extract those names: # export _gl_TS_var_match = \ -# /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/ -_gl_TS_var_match ?= /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?\])?;/ +# /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/ +_gl_TS_var_match ?= /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?])?;/ # The names of object files in (or relative to) $(_gl_TS_dir). _gl_TS_obj_files ?= *.$(OBJEXT) -- 2.37.2 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 05 02:48:29 2022 Received: (at 52835) by debbugs.gnu.org; 5 Sep 2022 06:48:29 +0000 Received: from localhost ([127.0.0.1]:46250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV5uH-0000bd-52 for submit@debbugs.gnu.org; Mon, 05 Sep 2022 02:48:29 -0400 Received: from jpoiret.xyz ([206.189.101.64]:38528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV5uF-0000bH-CR for 52835@debbugs.gnu.org; Mon, 05 Sep 2022 02:48:27 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 89DF118530C; Mon, 5 Sep 2022 06:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1662360506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=puvWFbocnfy6+9e0je87eDLt4ASL6ZhTFPo5Sa0wDg4=; b=CeGmxm6zf1RwYGrp2zgUeng0YqPYmEt1nkU6RAFqPRpQqnEhzVWoM7ViwtbqlyHpuAe7A8 IT7ngRC61JJXKVKkhRfOVvpYrOQYJfS7Dvqe2hx+aBE+P54PjfhWpY7TEIRW+Ci4RfLrmO PwOxnK85VkTtfpImOw9V5INiarvfFfaou4tc9CYSSLQZRuYg2LjkKLkbZ8K2icFPrXkYe/ frZUDHexgfCIsUCs7Tl1BXkRVE9DSKmxjstELD2wxt2CTPDIq4APKtWOj5XlwI2RfLGSGN Qp9lz1D9CwNAz0OkdWYKpBzO+r2CF9CXqCBHCF3oRhFdLkv/H/OltnV2SKds6A== From: Josselin Poiret To: 52835@debbugs.gnu.org Subject: [PATCH v5 2/3] Add spawn*. Date: Mon, 5 Sep 2022 08:48:14 +0200 Message-Id: <95dbb2e804221fc369203d38c75238a190d3ff6f.1662358976.git.dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c: Include spawn.h from Gnulib. (scm_spawn_process): New function. (scm_init_popen): Define spawn*. --- libguile/posix.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file c [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: Timothy Sample , Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) * libguile/posix.c: Include spawn.h from Gnulib. (scm_spawn_process): New function. (scm_init_popen): Define spawn*. --- libguile/posix.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/libguile/posix.c b/libguile/posix.c index f4ca72d3e..5d287ff2a 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef HAVE_SCHED_H # include @@ -1472,6 +1473,75 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to) } #undef FUNC_NAME +static SCM +scm_spawn_process (SCM prog, SCM args, SCM scm_in, SCM scm_out, SCM scm_err) +#define FUNC_NAME "spawn*" +{ + int in, out, err; + int pid; + char *exec_file; + char **exec_argv; + char **exec_env = NULL; + + posix_spawn_file_actions_t actions; + posix_spawnattr_t *attrp = NULL; + + exec_file = scm_to_locale_string (prog); + exec_argv = scm_i_allocate_string_pointers (args); + + in = scm_to_int (scm_in); + out = scm_to_int (scm_out); + err = scm_to_int (scm_err); + + int max_fd = 1024; + +#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) + { + struct rlimit lim = { 0, 0 }; + if (getrlimit (RLIMIT_NOFILE, &lim) == 0) + max_fd = lim.rlim_cur; + } +#endif + + posix_spawn_file_actions_init (&actions); + + int free_fd_slots = 0; + int fd_slot[3]; + + for (int fdnum = 3;free_fd_slots < 3 && fdnum < max_fd;fdnum++) + { + if (fdnum != in && fdnum != out && fdnum != err) + { + fd_slot[free_fd_slots] = fdnum; + free_fd_slots++; + } + } + + /* Move the fds out of the way, so that duplicate fds or fds equal + to 0, 1, 2 don't trample each other */ + + posix_spawn_file_actions_adddup2 (&actions, in, fd_slot[0]); + posix_spawn_file_actions_adddup2 (&actions, out, fd_slot[1]); + posix_spawn_file_actions_adddup2 (&actions, err, fd_slot[2]); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[0], 0); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[1], 1); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[2], 2); + + while (--max_fd > 2) + posix_spawn_file_actions_addclose (&actions, max_fd); + + if (posix_spawnp (&pid, exec_file, &actions, attrp, exec_argv, environ) != 0) + { + int errno_save = errno; + free (exec_file); + errno = errno_save; + SCM_SYSERROR; + } + + return scm_from_int (pid); +} +#undef FUNC_NAME + static void restore_sigaction (SCM pair) { @@ -2381,6 +2451,7 @@ static void scm_init_popen (void) { scm_c_define_gsubr ("piped-process", 2, 2, 0, scm_piped_process); + scm_c_define_gsubr ("spawn*", 5, 0, 0, scm_spawn_process); } #endif /* HAVE_START_CHILD */ -- 2.37.2 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 05 02:48:34 2022 Received: (at 52835) by debbugs.gnu.org; 5 Sep 2022 06:48:34 +0000 Received: from localhost ([127.0.0.1]:46252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV5uL-0000by-I2 for submit@debbugs.gnu.org; Mon, 05 Sep 2022 02:48:34 -0400 Received: from jpoiret.xyz ([206.189.101.64]:38528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV5uG-0000bH-07 for 52835@debbugs.gnu.org; Mon, 05 Sep 2022 02:48:29 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 5BFEA184F64; Mon, 5 Sep 2022 06:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1662360507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TU0vigAZ8oUicNTOj+bj0Ao7TnNtTjChjyVgmMKiWYI=; b=Reb7HfMT8oDpsz1eFU555m/ZJs9rcBEcMICL6nsg9B5I8/j7WjayUYhOH/G7llv82SelpD lu4i+Dc/VV9gzgjRMcXWYdYqyjM2XMYSYwteGxSbAjhF+PCkdAAfx2ppgQINiyjS+ir4hv VhX7MMLu92OgAyA45JeLCyCCqPQt66gIBEqQebPWvccQGLYAf4j4B1axevPHPVu8BLq64B 9FVil8JTCa5upLYGmh+DKhJSJWzEf8C5hKMoayYH35R1b3H+9SWeG+S1rtdnyRL3rSPss0 uXuYuSAQJBgR+oGQnHCOCrLFQw9WtgpxKaJilvQtZ9PVz//TuEypD+LjQ6e6Gw== From: Josselin Poiret To: 52835@debbugs.gnu.org Subject: [PATCH v5 3/3] Move popen and posix procedures to spawn*. Date: Mon, 5 Sep 2022 08:48:15 +0200 Message-Id: <1d64d8e0e292fc3a89bcd491dd8f10171cb7c804.1662358976.git.dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (renumber_file_descriptor, start_child, scm_piped_process): Remove functions. (scm_port_to_fd_with_default): New helper function. (scm_system_star): Rewrite using scm_spawn_process. [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: Timothy Sample , Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) * libguile/posix.c (renumber_file_descriptor, start_child, scm_piped_process): Remove functions. (scm_port_to_fd_with_default): New helper function. (scm_system_star): Rewrite using scm_spawn_process. (scm_init_popen): Remove the definition of piped-process. (scm_init_posix): Now make popen available unconditionally. * module/ice-9/popen.scm (port-with-defaults): New helper procedure. (spawn): New procedure. (open-process): Rewrite using spawn. (pipeline): Rewrite using spawn*. * test-suite/tests/popen.test ("piped-process", "piped-process: with-output"): Removed tests. ("spawn", "spawn: with output"): Added tests. * test-suite/tests/posix.test ("http://bugs.gnu.org/13166", "exit code for nonexistent file", "https://bugs.gnu.org/55596"): Remove obsolete tests. ("exception for nonexistent file"): Add test. --- libguile/posix.c | 218 +++--------------------------------- module/ice-9/popen.scm | 83 ++++++++++---- test-suite/tests/popen.test | 14 +-- test-suite/tests/posix.test | 36 +++--- 4 files changed, 102 insertions(+), 249 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 5d287ff2a..c35346f9f 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -73,6 +73,7 @@ #include "fports.h" #include "gettext.h" #include "gsubr.h" +#include "ioext.h" #include "list.h" #include "modules.h" #include "numbers.h" @@ -1280,199 +1281,6 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #undef FUNC_NAME #endif /* HAVE_FORK */ -#ifdef HAVE_FORK -/* 'renumber_file_descriptor' is a helper function for 'start_child' - below, and is specialized for that particular environment where it - doesn't make sense to report errors via exceptions. It uses dup(2) - to duplicate the file descriptor FD, closes the original FD, and - returns the new descriptor. If dup(2) fails, print an error message - to ERR and abort. */ -static int -renumber_file_descriptor (int fd, int err) -{ - int new_fd; - - do - new_fd = dup (fd); - while (new_fd == -1 && errno == EINTR); - - if (new_fd == -1) - { - /* At this point we are in the child process before exec. We - cannot safely raise an exception in this environment. */ - const char *msg = strerror (errno); - fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); - _exit (127); /* Use exit status 127, as with other exec errors. */ - } - - close (fd); - return new_fd; -} -#endif /* HAVE_FORK */ - -#ifdef HAVE_FORK -#define HAVE_START_CHILD 1 -/* Since Guile uses threads, we have to be very careful to avoid calling - functions that are not async-signal-safe in the child. That's why - this function is implemented in C. */ -static pid_t -start_child (const char *exec_file, char **exec_argv, - int reading, int c2p[2], int writing, int p2c[2], - int in, int out, int err) -{ - int pid; - int max_fd = 1024; - -#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) - { - struct rlimit lim = { 0, 0 }; - if (getrlimit (RLIMIT_NOFILE, &lim) == 0) - max_fd = lim.rlim_cur; - } -#endif - - pid = fork (); - - if (pid != 0) - /* The parent, with either and error (pid == -1), or the PID of the - child. Return directly in either case. */ - return pid; - - /* The child. */ - if (reading) - close (c2p[0]); - if (writing) - close (p2c[1]); - - /* Close all file descriptors in ports inherited from the parent - except for in, out, and err. Heavy-handed, but robust. */ - while (max_fd--) - if (max_fd != in && max_fd != out && max_fd != err) - close (max_fd); - - /* Ignore errors on these open() calls. */ - if (in == -1) - in = open ("/dev/null", O_RDONLY); - if (out == -1) - out = open ("/dev/null", O_WRONLY); - if (err == -1) - err = open ("/dev/null", O_WRONLY); - - if (in > 0) - { - if (out == 0) - out = renumber_file_descriptor (out, err); - if (err == 0) - err = renumber_file_descriptor (err, err); - do dup2 (in, 0); while (errno == EINTR); - close (in); - } - if (out > 1) - { - if (err == 1) - err = renumber_file_descriptor (err, err); - do dup2 (out, 1); while (errno == EINTR); - if (out > 2) - close (out); - } - if (err > 2) - { - do dup2 (err, 2); while (errno == EINTR); - close (err); - } - - execvp (exec_file, exec_argv); - - /* The exec failed! There is nothing sensible to do. */ - { - const char *msg = strerror (errno); - fprintf (fdopen (2, "a"), "In execvp of %s: %s\n", - exec_file, msg); - } - - /* Use exit status 127, like shells in this case, as per POSIX - . */ - _exit (127); - - /* Not reached. */ - return -1; -} -#endif - -#ifdef HAVE_START_CHILD -static SCM -scm_piped_process (SCM prog, SCM args, SCM from, SCM to) -#define FUNC_NAME "piped-process" -{ - int reading, writing; - int c2p[2]; /* Child to parent. */ - int p2c[2]; /* Parent to child. */ - int in = -1, out = -1, err = -1; - int pid; - char *exec_file; - char **exec_argv; - - exec_file = scm_to_locale_string (prog); - exec_argv = scm_i_allocate_string_pointers (scm_cons (prog, args)); - - reading = scm_is_pair (from); - writing = scm_is_pair (to); - - if (reading) - { - c2p[0] = scm_to_int (scm_car (from)); - c2p[1] = scm_to_int (scm_cdr (from)); - out = c2p[1]; - } - - if (writing) - { - p2c[0] = scm_to_int (scm_car (to)); - p2c[1] = scm_to_int (scm_cdr (to)); - in = p2c[0]; - } - - { - SCM port; - - if (SCM_OPOUTFPORTP ((port = scm_current_error_port ()))) - err = SCM_FPORT_FDES (port); - if (out == -1 && SCM_OPOUTFPORTP ((port = scm_current_output_port ()))) - out = SCM_FPORT_FDES (port); - if (in == -1 && SCM_OPINFPORTP ((port = scm_current_input_port ()))) - in = SCM_FPORT_FDES (port); - } - - pid = start_child (exec_file, exec_argv, reading, c2p, writing, p2c, - in, out, err); - - if (pid == -1) - { - int errno_save = errno; - free (exec_file); - if (reading) - { - close (c2p[0]); - close (c2p[1]); - } - if (writing) - { - close (p2c[0]); - close (p2c[1]); - } - errno = errno_save; - SCM_SYSERROR; - } - - if (reading) - close (c2p[1]); - if (writing) - close (p2c[0]); - - return scm_from_int (pid); -} -#undef FUNC_NAME - static SCM scm_spawn_process (SCM prog, SCM args, SCM scm_in, SCM scm_out, SCM scm_err) #define FUNC_NAME "spawn*" @@ -1563,6 +1371,15 @@ scm_dynwind_sigaction (int sig, SCM handler, SCM flags) SCM_F_WIND_EXPLICITLY); } +static SCM +scm_port_to_fd_with_default (SCM port, int mode) +{ + if (!SCM_FPORTP (port)) + return scm_from_int (open_or_open64 ("/dev/null", mode)); + return scm_fileno (port); + +} + SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, (SCM args), "Execute the command indicated by @var{args}. The first element must\n" @@ -1589,7 +1406,6 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, if (scm_is_null (args)) SCM_WRONG_NUM_ARGS (); prog = scm_car (args); - args = scm_cdr (args); scm_dynwind_begin (0); /* Make sure the child can't kill us (as per normal system call). */ @@ -1602,7 +1418,13 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, SCM_UNDEFINED); #endif - pid = scm_piped_process (prog, args, SCM_UNDEFINED, SCM_UNDEFINED); + SCM in, out, err; + + in = scm_port_to_fd_with_default (scm_current_input_port (), O_RDONLY); + out = scm_port_to_fd_with_default (scm_current_output_port (), O_WRONLY); + err = scm_port_to_fd_with_default (scm_current_error_port (), O_WRONLY); + + pid = scm_spawn_process (prog, args, in, out, err); SCM_SYSCALL (wait_result = waitpid (scm_to_int (pid), &status, 0)); if (wait_result == -1) SCM_SYSERROR; @@ -1612,7 +1434,6 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, return scm_from_int (status); } #undef FUNC_NAME -#endif /* HAVE_START_CHILD */ #ifdef HAVE_UNAME SCM_DEFINE (scm_uname, "uname", 0, 0, 0, @@ -2446,14 +2267,11 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0, #endif /* HAVE_GETHOSTNAME */ -#ifdef HAVE_START_CHILD static void scm_init_popen (void) { - scm_c_define_gsubr ("piped-process", 2, 2, 0, scm_piped_process); scm_c_define_gsubr ("spawn*", 5, 0, 0, scm_spawn_process); } -#endif /* HAVE_START_CHILD */ void scm_init_posix () @@ -2566,11 +2384,9 @@ scm_init_posix () #ifdef HAVE_FORK scm_add_feature ("fork"); #endif /* HAVE_FORK */ -#ifdef HAVE_START_CHILD scm_add_feature ("popen"); scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION, "scm_init_popen", (scm_t_extension_init_func) scm_init_popen, NULL); -#endif /* HAVE_START_CHILD */ } diff --git a/module/ice-9/popen.scm b/module/ice-9/popen.scm index e638726a4..533282f4d 100644 --- a/module/ice-9/popen.scm +++ b/module/ice-9/popen.scm @@ -25,12 +25,37 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:export (port/pid-table open-pipe* open-pipe close-pipe open-input-pipe - open-output-pipe open-input-output-pipe pipeline)) + open-output-pipe open-input-output-pipe pipeline + spawn* spawn)) (eval-when (expand load eval) (load-extension (string-append "libguile-" (effective-version)) "scm_init_popen")) +(define (port-with-defaults port default-mode) + (if (file-port? port) + port + (open-file "/dev/null" default-mode))) + +(define* (spawn exec-file argv #:key + (in (current-input-port)) + (out (current-output-port)) + (err (current-error-port))) + (let* ((in (port-with-defaults in "r")) + (out (port-with-defaults out "w")) + (err (port-with-defaults err "w")) + ;; Increment port revealed counts while to prevent ports GC'ing and + ;; closing the associated fds while we spawn the process. + (result (spawn* exec-file + argv + (port->fdes in) + (port->fdes out) + (port->fdes err)))) + (release-port-handle in) + (release-port-handle out) + (release-port-handle err) + result)) + (define-record-type (make-pipe-info pid) pipe-info? @@ -92,13 +117,13 @@ (define (open-process mode command . args) "Backwards compatible implementation of the former procedure in -libguile/posix.c (scm_open_process) replaced by -scm_piped_process. Executes the program @var{command} with optional -arguments @var{args} (all strings) in a subprocess. A port to the -process (based on pipes) is created and returned. @var{mode} specifies -whether an input, an output or an input-output port to the process is -created: it should be the value of @code{OPEN_READ}, @code{OPEN_WRITE} -or @code{OPEN_BOTH}." +libguile/posix.c (scm_open_process) replaced by scm_piped_process, now +replaced by scm_spawn_process. Executes the program @var{command} with +optional arguments @var{args} (all strings) in a subprocess. A port to +the process (based on pipes) is created and returned. @var{mode} +specifies whether an input, an output or an input-output port to the +process is created: it should be the value of @code{OPEN_READ}, +@code{OPEN_WRITE} or @code{OPEN_BOTH}." (define (unbuffered port) (setvbuf port 'none) port) @@ -107,19 +132,25 @@ or @code{OPEN_BOTH}." (and ports (cons (port->fdes (car ports)) (port->fdes (cdr ports))))) - (let* ((from (and (or (string=? mode OPEN_READ) - (string=? mode OPEN_BOTH)) - (pipe))) - (to (and (or (string=? mode OPEN_WRITE) - (string=? mode OPEN_BOTH)) - (pipe))) - (pid (piped-process command args - (fdes-pair from) - (fdes-pair to)))) + (let* ((child-to-parent (and (or (string=? mode OPEN_READ) + (string=? mode OPEN_BOTH)) + (pipe))) + (parent-to-child (and (or (string=? mode OPEN_WRITE) + (string=? mode OPEN_BOTH)) + (pipe))) + (in (or (and=> parent-to-child car) (current-input-port))) + (out (or (and=> child-to-parent cdr) (current-output-port))) + (pid (spawn command (cons command args) + #:in in + #:out out))) + (when child-to-parent + (close (cdr child-to-parent))) + (when parent-to-child + (close (car parent-to-child))) ;; The original 'open-process' procedure would return unbuffered ;; ports; do the same here. - (values (and from (unbuffered (car from))) - (and to (unbuffered (cdr to))) + (values (and child-to-parent (unbuffered (car child-to-parent))) + (and parent-to-child (unbuffered (cdr parent-to-child))) pid))) (define (open-pipe* mode command . args) @@ -224,10 +255,16 @@ a list of PIDs of the processes executing the @var{commands}." (pipeline (fold (lambda (from proc prev) (let* ((to (car prev)) (pids (cdr prev)) - (pid (piped-process (car proc) - (cdr proc) - from - to))) + (pid (spawn* (car proc) + proc + (car to) + (cdr from) + (port->fdes + (port-with-defaults + (current-error-port) + "w"))))) + (close-fdes (car to)) + (close-fdes (cdr from)) (cons from (cons pid pids)))) `(,to) pipes diff --git a/test-suite/tests/popen.test b/test-suite/tests/popen.test index 3df863375..fd810e376 100644 --- a/test-suite/tests/popen.test +++ b/test-suite/tests/popen.test @@ -257,18 +257,18 @@ exec 2>~a; read REPLY" (list (read-string from) (status:exit-val (cdr (waitpid pid)))))) -(pass-if-equal "piped-process" +(pass-if-equal "spawn" 42 (status:exit-val - (cdr (waitpid ((@@ (ice-9 popen) piped-process) - "./meta/guile" '("-c" "(exit 42)")))))) + (cdr (waitpid (spawn + "./meta/guile" '("./meta/guile" "-c" "(exit 42)")))))) -(pass-if-equal "piped-process: with output" +(pass-if-equal "spawn: with output" '("foo bar\n" 0) (let* ((p (pipe)) - (pid ((@@ (ice-9 popen) piped-process) "echo" '("foo" "bar") - (cons (port->fdes (car p)) - (port->fdes (cdr p)))))) + (pid (spawn "echo" '("echo" "foo" "bar") + #:out (cdr p)))) + (close (cdr p)) (list (read-string (car p)) (status:exit-val (cdr (waitpid pid)))))) diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test index 500dbb94a..157f21e24 100644 --- a/test-suite/tests/posix.test +++ b/test-suite/tests/posix.test @@ -236,24 +236,24 @@ (with-test-prefix "system*" - (pass-if "http://bugs.gnu.org/13166" - ;; With Guile up to 2.0.7 included, the child process launched by - ;; `system*' would remain alive after an `execvp' failure. - (let ((me (getpid))) - (and (not (zero? (system* "something-that-does-not-exist"))) - (= me (getpid))))) - - (pass-if-equal "exit code for nonexistent file" - 127 ;aka. EX_NOTFOUND - (status:exit-val (system* "something-that-does-not-exist"))) - - (pass-if-equal "https://bugs.gnu.org/55596" - 127 - ;; The parameterization below used to cause 'start_child' to close - ;; fd 2 in the child process, which in turn would cause it to - ;; segfault, leading to a wrong exit code. - (parameterize ((current-output-port (current-error-port))) - (status:exit-val (system* "something-that-does-not-exist"))))) + (pass-if-equal "exception for nonexistent file" + 2 ; ENOENT + (call-with-prompt 'escape + (lambda () + (with-exception-handler + (lambda (exn) + (let* ((kind (exception-kind exn)) + (errno (and (eq? kind 'system-error) + (car (car + (cdr (cdr (cdr (exception-args + exn))))))))) + (abort-to-prompt 'escape errno))) + (lambda () + (status:exit-val (system* + "something-that-does-not-exist"))) + #:unwind? #t)) + (lambda (k arg) + arg)))) ;; ;; crypt -- 2.37.2 From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 29 10:05:59 2022 Received: (at 52835) by debbugs.gnu.org; 29 Nov 2022 15:05:59 +0000 Received: from localhost ([127.0.0.1]:54626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p02BE-0003Q8-6w for submit@debbugs.gnu.org; Tue, 29 Nov 2022 10:05:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54744) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p02B9-0003Q1-VX for 52835@debbugs.gnu.org; Tue, 29 Nov 2022 10:05:51 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p02B3-0005W1-Q4; Tue, 29 Nov 2022 10:05:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=+whozZqY7Owv/m2bJZrjq7uG9LXyPSDhyrsypwHPcjg=; b=qVDInaV3q22su+Gnm47Z mZxXbSwZ/kIkQQDrvUO2pjX+PMvCLrIs7tlE9h6W099ILsP6EWwqClNi0VUvwBc30dbhgK/bVMSxr ozGbNDXIj/arFvPN17kZNVrx0Chea0TgAHO1pB2r8I26GYvFqhYOOLItz4l5zfnrWdzfpquovqLZ0 Uuqi87v3QEiKyK8a3abUY9MHrgMG++94d+1HroBaJth5UWvOEIDphTeONeuP2Gw1XUs23K2nz2AbJ CniVQ60rBf3UVDL2ajkfoD+ohSmvgojULW1ThD/gbxEH5jRWDkkOS0QK6e7PzvI1MhM/4OjAOF0qw CTBJjKwvGFKpdw==; Received: from [193.50.110.137] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p02AZ-0006jJ-MW; Tue, 29 Nov 2022 10:05:39 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Josselin Poiret Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: <1d64d8e0e292fc3a89bcd491dd8f10171cb7c804.1662358976.git.dev@jpoiret.xyz> Date: Tue, 29 Nov 2022 16:05:05 +0100 In-Reply-To: <1d64d8e0e292fc3a89bcd491dd8f10171cb7c804.1662358976.git.dev@jpoiret.xyz> (Josselin Poiret's message of "Mon, 5 Sep 2022 08:48:15 +0200") Message-ID: <875yex4x9a.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hi Josselin, Sorry for taking so long to come back to you. I think this is great work! I pushed it as =E2=80=98wip-posix-spawn=E2=80=99 so others can give = it a try. Josselin Poiret skribis: > * libguile/posix.c (renumber_file_descriptor, start_child, > scm_piped_process): Remove functions. > (scm_port_to_fd_with_default): New helper function. > (scm_system_star): Rewrite using scm_spawn_process. > (scm_init_popen): Remove the definition of piped-process. > (scm_init_posix): Now make popen available unconditionally. > > * module/ice-9/popen.scm (port-with-defaults): New helper procedure. > (spawn): New procedure. > (open-process): Rewrite using spawn. > (pipeline): Rewrite using spawn*. > > * test-suite/tests/popen.test ("piped-process", "piped-process: > with-output"): Removed tests. > ("spawn", "spawn: with output"): Added tests. > * test-suite/tests/posix.test ("http://bugs.gnu.org/13166", "exit code > for nonexistent file", "https://bugs.gnu.org/55596"): Remove obsolete > tests. > ("exception for nonexistent file"): Add test. > --- > libguile/posix.c | 218 +++--------------------------------- > module/ice-9/popen.scm | 83 ++++++++++---- > test-suite/tests/popen.test | 14 +-- > test-suite/tests/posix.test | 36 +++--- > 4 files changed, 102 insertions(+), 249 deletions(-) More deletions than insertions. =F0=9F=91=8D That scary-looking Gnulib update seems to have worked well. I have mostly cosmetic/polishing comments and one issue with =E2=80=98syste= m*=E2=80=99. I can actually do that on your behalf if you=E2=80=99re unavailable these d= ays; let me know what you prefer. > static SCM > scm_spawn_process (SCM prog, SCM args, SCM scm_in, SCM scm_out, SCM scm_= err) > #define FUNC_NAME "spawn*" For top-level functions, please add a comment above explaining what it does. I would call this one =E2=80=98primitive-spawn=E2=80=99 rather than =E2=80= =98spawn*=E2=80=99 and keep it private to (ice-9 popen). > +(define* (spawn exec-file argv #:key > + (in (current-input-port)) > + (out (current-output-port)) > + (err (current-error-port))) Please add a docstring. It may also be worth documenting it in the manual given that it=E2=80=99s public. > + (let* ((in (port-with-defaults in "r")) > + (out (port-with-defaults out "w")) > + (err (port-with-defaults err "w")) I=E2=80=99d make it =E2=80=9Cr0=E2=80=9D and =E2=80=9Cw0=E2=80=9D since we= =E2=80=99re doing to throw the ports away right after. We could even avoid allocating a port when we=E2=80=99re going to use /dev/= null (and thus go with =E2=80=98open-fdes=E2=80=99 directly), but that=E2=80=99s= a micro-optimization we can keep for later. > +++ b/test-suite/tests/posix.test > @@ -236,24 +236,24 @@ >=20=20 > (with-test-prefix "system*" >=20=20 > - (pass-if "http://bugs.gnu.org/13166" > - ;; With Guile up to 2.0.7 included, the child process launched by > - ;; `system*' would remain alive after an `execvp' failure. > - (let ((me (getpid))) > - (and (not (zero? (system* "something-that-does-not-exist"))) > - (=3D me (getpid))))) I=E2=80=99d keep this one, I guess it doesn=E2=80=99t hurt? > - (pass-if-equal "exit code for nonexistent file" > - 127 ;aka. EX_NOTFOUND > - (status:exit-val (system* "something-that-does-not-exist"))) It=E2=80=99s good that we have better error reporting thanks to =E2=80=98po= six_spawn=E2=80=99. However, I don=E2=80=99t think we can change that in 3.0. What about, for = 3.0, adding a layer around =E2=80=98spawn=E2=80=99 so that =E2=80=98system*=E2= =80=99 still returns 127 when =E2=80=98spawn=E2=80=99 throws to =E2=80=98system-error=E2=80=99? > - (pass-if-equal "https://bugs.gnu.org/55596" > - 127 > - ;; The parameterization below used to cause 'start_child' to close > - ;; fd 2 in the child process, which in turn would cause it to > - ;; segfault, leading to a wrong exit code. > - (parameterize ((current-output-port (current-error-port))) > - (status:exit-val (system* "something-that-does-not-exist"))))) Likewise we should keep this one. > + (pass-if-equal "exception for nonexistent file" > + 2 ; ENOENT > + (call-with-prompt 'escape > + (lambda () > + (with-exception-handler > + (lambda (exn) > + (let* ((kind (exception-kind exn)) > + (errno (and (eq? kind 'system-error) > + (car (car > + (cdr (cdr (cdr (exception-args > + exn))))))))) > + (abort-to-prompt 'escape errno))) > + (lambda () > + (status:exit-val (system* > + "something-that-does-not-exist"))) > + #:unwind? #t)) > + (lambda (k arg) > + arg)))) We=E2=80=99ll have to leave this change for the next major series of Guile. Thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 15:16:39 2022 Received: (at 52835) by debbugs.gnu.org; 11 Dec 2022 20:16:39 +0000 Received: from localhost ([127.0.0.1]:48021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4SkY-0002c3-Sc for submit@debbugs.gnu.org; Sun, 11 Dec 2022 15:16:39 -0500 Received: from jpoiret.xyz ([206.189.101.64]:49896) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4SkW-0002bx-MH for 52835@debbugs.gnu.org; Sun, 11 Dec 2022 15:16:37 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id E62DC184BB1; Sun, 11 Dec 2022 20:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1670789795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Slo+URMtib6/BRc1ULAEzarfAkDZhcnWmskVOaKwWeU=; b=Wp2DWc4Kx/nrFo8hLO1/3ez986ocyA7/v/Ld1KQEBpHYczLlPXryoIN1hyU00l6ypRfsbJ 7hImuK3dcEURyhPfVcvGK2CJv7NNzXMLsVr60J3SRNLz2pb+/hVE3i/v8lSAZL/J3c79ja PVRtSNAY1pZRlTOvGMwQ0yIIN2KbR6mY3YILKCr4JAl1W8FIEVSRYed1czvUKc5sm3eVQx pT6lgBuEVpVAB0XNu0pWCwreTKVvJxqWl7wa/WTsujFCJOsZXLJDu0pu9IMPWOSIMTUNnW UVevYS93cWnXRjHrvhfd1i1EZ12hOHVsMN6y1CaizdzPTPXjV4xIWcxby1b8IQ== From: Josselin Poiret To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly In-Reply-To: <875yex4x9a.fsf_-_@gnu.org> References: <1d64d8e0e292fc3a89bcd491dd8f10171cb7c804.1662358976.git.dev@jpoiret.xyz> <875yex4x9a.fsf_-_@gnu.org> Date: Sun, 11 Dec 2022 21:16:34 +0100 Message-ID: <87sfhl8zml.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi Ludo, Ludovic Courtès writes: > For top-level functions, please add a comment above explaining what it > does. Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi Ludo, Ludovic Courtès writes: > For top-level functions, please add a comment above explaining what it > does. Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager Hi Ludo,=20 Ludovic Court=C3=A8s writes: > For top-level functions, please add a comment above explaining what it > does. Completely forgot about that. I will do it at some point, however we will need to settle on how to resolve the issue at the bottom first. > I would call this one =E2=80=98primitive-spawn=E2=80=99 rather than =E2= =80=98spawn*=E2=80=99 and keep it > private to (ice-9 popen). Is there any reason we would want this to not be accessible to the user? There are already a bunch of functions that manipulate raw fdes, and people might want to directly use this to not have to care about ports. > Please add a docstring. It may also be worth documenting it in the > manual given that it=E2=80=99s public. > >> + (let* ((in (port-with-defaults in "r")) >> + (out (port-with-defaults out "w")) >> + (err (port-with-defaults err "w")) > > I=E2=80=99d make it =E2=80=9Cr0=E2=80=9D and =E2=80=9Cw0=E2=80=9D since w= e=E2=80=99re doing to throw the ports away > right after. Sure. > We could even avoid allocating a port when we=E2=80=99re going to use /de= v/null > (and thus go with =E2=80=98open-fdes=E2=80=99 directly), but that=E2=80= =99s a micro-optimization > we can keep for later. Right. I chose to keep the code simple for now, it's too much trouble having to choose between using ports and fdes. Note that I did a small benchmark and system* with PATCH v5 is 3x faster than on 3.0.8. vfork is working wonders. >> +++ b/test-suite/tests/posix.test >> @@ -236,24 +236,24 @@ >>=20=20 >> (with-test-prefix "system*" >>=20=20 >> - (pass-if "http://bugs.gnu.org/13166" >> - ;; With Guile up to 2.0.7 included, the child process launched by >> - ;; `system*' would remain alive after an `execvp' failure. >> - (let ((me (getpid))) >> - (and (not (zero? (system* "something-that-does-not-exist"))) >> - (=3D me (getpid))))) > > I=E2=80=99d keep this one, I guess it doesn=E2=80=99t hurt? As is, it doesn't work since system* would throw a system exception because spawn is able to catch that error. Previously, the child would fail its execvp and die with exit code 127, which system* would return. >> - (pass-if-equal "exit code for nonexistent file" >> - 127 ;aka. EX_NOTFOUND >> - (status:exit-val (system* "something-that-does-not-exist"))) > > It=E2=80=99s good that we have better error reporting thanks to =E2=80=98= posix_spawn=E2=80=99. > > However, I don=E2=80=99t think we can change that in 3.0. What about, fo= r 3.0, > adding a layer around =E2=80=98spawn=E2=80=99 so that =E2=80=98system*=E2= =80=99 still returns 127 when > =E2=80=98spawn=E2=80=99 throws to =E2=80=98system-error=E2=80=99? So I've been working on something that would do this, but I noticed that we have no way to be strictly backwards-compatible: if there's an error like ENOFILE, we can't get a pid from posix_spawn, and so piped-process won't have anything to return, whereas before it would return the pid of the failing child. I'm not sure there's a way to emulate that, unless we just fork a child that instantly returns 127. Doesn't seem great though. WDYT? --=20 Josselin Poiret From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 12 18:49:17 2022 Received: (at 52835) by debbugs.gnu.org; 12 Dec 2022 23:49:17 +0000 Received: from localhost ([127.0.0.1]:56294 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4sXs-0008VF-Sb for submit@debbugs.gnu.org; Mon, 12 Dec 2022 18:49:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4sXr-0008V9-FR for 52835@debbugs.gnu.org; Mon, 12 Dec 2022 18:49:15 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4sXl-0003yL-Rv; Mon, 12 Dec 2022 18:49:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=XYwJjWnNjOc2/C4Rpc3acPcTFtAs3Sy1M7X3/5g+hVc=; b=KMj3rmPtteT6KHXDojqC JKCvu35OoJ2tujPnYLcAqP9tuLEuHG5llD66W5wELuhLgrsMCVh/lZ3XkDY7K0b2XGl5ad7qZZXuU oXTxtJBnG2dXsxeqCi/OTyKzLe5GovT65nkU3c5eqfDSL+Lmcglk7Y9qppjmvbcYrdqBKmWDpMRFJ M6nInwGAIkBa7O7BqhE7i9qbEP6wqOoWuZD+aYdI9sOzpheXZbV8tUfDOez3nBpzVfDWChnx5iMRm GR+uAZJONNT6MX2XuspOR/spJ9d5lf9xF62aUQlTbLJejJoT+prabjEs87YuaKsTbH2HE5Nn5Ap4S 7fyp4CaH/ybZYw==; Received: from [82.66.71.168] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4sXl-0006t3-ET; Mon, 12 Dec 2022 18:49:09 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Josselin Poiret Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: <1d64d8e0e292fc3a89bcd491dd8f10171cb7c804.1662358976.git.dev@jpoiret.xyz> <875yex4x9a.fsf_-_@gnu.org> <87sfhl8zml.fsf@jpoiret.xyz> Date: Tue, 13 Dec 2022 00:49:06 +0100 In-Reply-To: <87sfhl8zml.fsf@jpoiret.xyz> (Josselin Poiret's message of "Sun, 11 Dec 2022 21:16:34 +0100") Message-ID: <87iligyyh9.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hello, Josselin Poiret skribis: >> I would call this one =E2=80=98primitive-spawn=E2=80=99 rather than =E2= =80=98spawn*=E2=80=99 and keep it >> private to (ice-9 popen). > > Is there any reason we would want this to not be accessible to the user? > There are already a bunch of functions that manipulate raw fdes, and > people might want to directly use this to not have to care about ports. Yeah, on second thought I think you=E2=80=99re right: it be can be useful to have it exposed to users. In fact, I think we should provide interfaces that make =E2=80=98primitive-= fork=E2=80=99 unnecessary for most use cases. Exposing that procedure is a step in that direction. >> We could even avoid allocating a port when we=E2=80=99re going to use /d= ev/null >> (and thus go with =E2=80=98open-fdes=E2=80=99 directly), but that=E2=80= =99s a micro-optimization >> we can keep for later. > > Right. I chose to keep the code simple for now, it's too much trouble > having to choose between using ports and fdes. Note that I did a small > benchmark and system* with PATCH v5 is 3x faster than on 3.0.8. vfork > is working wonders. Nice! >>> +++ b/test-suite/tests/posix.test >>> @@ -236,24 +236,24 @@ >>>=20=20 >>> (with-test-prefix "system*" >>>=20=20 >>> - (pass-if "http://bugs.gnu.org/13166" >>> - ;; With Guile up to 2.0.7 included, the child process launched by >>> - ;; `system*' would remain alive after an `execvp' failure. >>> - (let ((me (getpid))) >>> - (and (not (zero? (system* "something-that-does-not-exist"))) >>> - (=3D me (getpid))))) >> >> I=E2=80=99d keep this one, I guess it doesn=E2=80=99t hurt? > > As is, it doesn't work since system* would throw a system exception > because spawn is able to catch that error. Previously, the child would > fail its execvp and die with exit code 127, which system* would return. > >>> - (pass-if-equal "exit code for nonexistent file" >>> - 127 ;aka. EX_NOTFOUND >>> - (status:exit-val (system* "something-that-does-not-exist"))) >> >> It=E2=80=99s good that we have better error reporting thanks to =E2=80= =98posix_spawn=E2=80=99. >> >> However, I don=E2=80=99t think we can change that in 3.0. What about, f= or 3.0, >> adding a layer around =E2=80=98spawn=E2=80=99 so that =E2=80=98system*= =E2=80=99 still returns 127 when >> =E2=80=98spawn=E2=80=99 throws to =E2=80=98system-error=E2=80=99? > > So I've been working on something that would do this, but I noticed that > we have no way to be strictly backwards-compatible: if there's an error > like ENOFILE, we can't get a pid from posix_spawn, and so piped-process > won't have anything to return, whereas before it would return the pid of > the failing child. I'm not sure there's a way to emulate that, unless > we just fork a child that instantly returns 127. Doesn't seem great > though. Right now =E2=80=98system*=E2=80=99 does: pid =3D scm_spawn_process (prog, args, in, out, err); SCM_SYSCALL (wait_result =3D waitpid (scm_to_int (pid), &status, 0)); if (wait_result =3D=3D -1) SCM_SYSERROR; How about introducing decomposing =E2=80=98scm_spawn_process=E2=80=99 so th= at we have a lower-level function we could use (=E2=80=98spawn_process=E2=80=99 below), = roughly like so: ret =3D spawn_process (proc, args, in, out, err, &pid); if (ret !=3D 0) { if (ret =3D=3D ENOMEM) { errno =3D ENOMEM; SCM_SYSERROR; } else /* Emulate old-style failure. TODO: In 3.2, turn that into an exception */ status =3D 127 << 8; } else SCM_SYSCALL (wait_result =3D waitpid (scm_to_int (pid), &status, 0)); Does that make sense? It=E2=80=99s a bit of work to emulate that suboptimal behavior, but I think= it=E2=80=99s important not to change that in 3.0. Thanks for your feedback! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 22 07:49:34 2022 Received: (at 52835) by debbugs.gnu.org; 22 Dec 2022 12:49:34 +0000 Received: from localhost ([127.0.0.1]:58187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8L0v-0001bs-L2 for submit@debbugs.gnu.org; Thu, 22 Dec 2022 07:49:34 -0500 Received: from jpoiret.xyz ([206.189.101.64]:41518) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8L0t-0001ba-HF for 52835@debbugs.gnu.org; Thu, 22 Dec 2022 07:49:32 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 0AA45185305; Thu, 22 Dec 2022 12:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1671713369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qIy2JR8YVDC78mvLqPjgXbrJfamy1NNzy3nDbntYMz8=; b=Uw93EYIH+IldyR0qGSKkGg39oua3ls3OixDIMZKEIX0NL7onK6pizBe+mO+3V1IDH5ZSSC LbtTnEPanSnTBrEiYC5UFIB0ybt++twefkMcS0qXdxlxp/kwNI2oSDkJgFPgcukOnsCrcy sUWSz5ZeLfAPfFr7WnI1OBgZMsiaHtbrNCFRvgzTWMNxiaI6cHlcvxeu8JPd3bYDIRa8w8 tBW//Nfe+I7HZVT+jrQxmkguUFIs+j+DgI7wql69rv9c0/zRAnQn+S0bis1SH2XOV/i8Mh GbYD9Z37MB4/hahWu2fq/42C7REjacOGK+aX7slhCnvm1rc17Eu6qJoV+RObzQ== From: Josselin Poiret To: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v6 1/3] Add spawn*. Date: Thu, 22 Dec 2022 13:49:08 +0100 Message-Id: <93fe711248cf1ebe86a03bb273ae76e86342ddf8.1671710701.git.dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c: Include spawn.h from Gnulib. (do_spawn, scm_spawn_process): New functions. --- libguile/posix.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ libguile/posix.h | 2 ++ 2 file [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample , Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) * libguile/posix.c: Include spawn.h from Gnulib. (do_spawn, scm_spawn_process): New functions. --- libguile/posix.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ libguile/posix.h | 2 ++ 2 files changed, 83 insertions(+) diff --git a/libguile/posix.c b/libguile/posix.c index b5352c2c4..e92625483 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef HAVE_SCHED_H # include @@ -1426,6 +1427,86 @@ start_child (const char *exec_file, char **exec_argv, } #endif +static int +do_spawn (char *exec_file, char **exec_argv, char **exec_env, int in, int out, int err) +{ + int pid = -1; + + posix_spawn_file_actions_t actions; + posix_spawnattr_t *attrp = NULL; + + int max_fd = 1024; + +#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) + { + struct rlimit lim = { 0, 0 }; + if (getrlimit (RLIMIT_NOFILE, &lim) == 0) + max_fd = lim.rlim_cur; + } +#endif + + posix_spawn_file_actions_init (&actions); + + int free_fd_slots = 0; + int fd_slot[3]; + + for (int fdnum = 3;free_fd_slots < 3 && fdnum < max_fd;fdnum++) + { + if (fdnum != in && fdnum != out && fdnum != err) + { + fd_slot[free_fd_slots] = fdnum; + free_fd_slots++; + } + } + + /* Move the fds out of the way, so that duplicate fds or fds equal + to 0, 1, 2 don't trample each other */ + + posix_spawn_file_actions_adddup2 (&actions, in, fd_slot[0]); + posix_spawn_file_actions_adddup2 (&actions, out, fd_slot[1]); + posix_spawn_file_actions_adddup2 (&actions, err, fd_slot[2]); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[0], 0); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[1], 1); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[2], 2); + + while (--max_fd > 2) + posix_spawn_file_actions_addclose (&actions, max_fd); + + if (posix_spawnp (&pid, exec_file, &actions, attrp, exec_argv, environ) != 0) + return -1; + + return pid; +} + +SCM_DEFINE (scm_spawn_process, "spawn*", 5, 0, 0, + (SCM prog, SCM args, SCM in, SCM out, SCM err), +"Spawns a new child process executing @var{prog} with arguments\n" +"@var{args}, with its standard input, output and error file descriptors\n" +"set to @var{in}, @var{out}, @var{err}.") +#define FUNC_NAME s_scm_spawn_process +{ + int pid; + char *exec_file; + char **exec_argv; + char **exec_env = environ; + + exec_file = scm_to_locale_string (prog); + exec_argv = scm_i_allocate_string_pointers (args); + + pid = do_spawn (exec_file, exec_argv, exec_env, + scm_to_int (in), + scm_to_int (out), + scm_to_int (err)); + + free (exec_file); + + if (pid == -1) + SCM_SYSERROR; + + return scm_from_int (pid); +} +#undef FUNC_NAME + #ifdef HAVE_START_CHILD static SCM scm_piped_process (SCM prog, SCM args, SCM from, SCM to) diff --git a/libguile/posix.h b/libguile/posix.h index 6504eaea8..c2703f9ab 100644 --- a/libguile/posix.h +++ b/libguile/posix.h @@ -69,6 +69,8 @@ SCM_API SCM scm_tmpnam (void); SCM_API SCM scm_tmpfile (void); SCM_API SCM scm_open_pipe (SCM pipestr, SCM modes); SCM_API SCM scm_close_pipe (SCM port); +SCM_API SCM scm_spawn_process (SCM prog, SCM args, + SCM in, SCM out, SCM err); SCM_API SCM scm_system_star (SCM cmds); SCM_API SCM scm_utime (SCM object, SCM actime, SCM modtime, SCM actimens, SCM modtimens, SCM flags); -- 2.38.1 From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 22 07:49:34 2022 Received: (at 52835) by debbugs.gnu.org; 22 Dec 2022 12:49:34 +0000 Received: from localhost ([127.0.0.1]:58189 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8L0w-0001bv-82 for submit@debbugs.gnu.org; Thu, 22 Dec 2022 07:49:34 -0500 Received: from jpoiret.xyz ([206.189.101.64]:41520) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8L0t-0001bZ-H8 for 52835@debbugs.gnu.org; Thu, 22 Dec 2022 07:49:32 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 684B1184B84; Thu, 22 Dec 2022 12:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1671713368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=INGLaZ/y9M1o6HXPSbbKmTyReKP077k344NNj26lGsA=; b=v5b/+LbvbmS/6bsy8sAp0Jdj+wPu1MC9oHIYtbXqAJYnRBui05myz0gB1zIJNTA/S6/k5j BrPEVYx1o+JF/0nVPqvwx9Do64DMzAWkfHXEOxczMlD2pwfWGZqvz34ELWWmED/mWbvolw iAqohPMdTFgNcDjoUJrf0yQeO+K/FQH3TtwXz+yJG6MOcUExk9pRHKe+CUPXHeulKf2HEb 6/Vy5Kd4wnXdalJIHRWHPQoPyycEZw/KIj79TTaNlGINqwCG4p0x/bpTPO/YDQWL4wEOs/ fg1dnTBMYuuasEHK0HD4YdojudsJf1HrRQ53FMEmbBrlrU8+7WQvIHQ1JfF5uA== From: Josselin Poiret To: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v6 0/3] Move spawning procedures to posix_spawn. Date: Thu, 22 Dec 2022 13:49:07 +0100 Message-Id: In-Reply-To: <87iligyyh9.fsf@gnu.org> References: <87iligyyh9.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Level: **** X-Spamd-Bar: ++++ X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello Ludo, Here is hopefully the last reroll of this patchset. First of all, I did not include the gnulib patch again because it still applies cleanly and it is extremely large, but it should be applied before t [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample , Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Hello Ludo, Here is hopefully the last reroll of this patchset. First of all, I did not include the gnulib patch again because it still applies cleanly and it is extremely large, but it should be applied before those 3 patches. The first two patches should be applied on the current major release, while the third one should be applied on the next major release to finish the migration to spawn. The first patch adds the new spawn* procedure, using an internal do_spawn function. The second patch changes system* and piped-process to use this new function, but it still tries to mimick the old behavior of start_child by inspecting the possible errnos, and spawning a dummy child that instantly exits with code 127 in some cases. The third patch gets rid of those special cases, which makes system* and friends throw more exceptions instead of having the child fail with exit code 127 (note that YMMV depending on how spawn is implemented for your system). I've added docstrings to user-facing Guile procedures, and also did the micro-optimization we talked about, since I had already factorized do_spawn. The tests seem to pass both with and without 3. One nice thing I've noticed is that gnulib has posix_spawn for WinNT as well, which means it might be okay to remove the dependency on having fork for system*, among others! WDYT? Josselin Poiret (3): Add spawn*. Make system* and piped-process internally use spawn. Move popen and posix procedures to spawn*. libguile/posix.c | 248 +++++++++++------------------------- libguile/posix.h | 2 + module/ice-9/popen.scm | 87 +++++++++---- test-suite/tests/popen.test | 14 +- test-suite/tests/posix.test | 36 +++--- 5 files changed, 161 insertions(+), 226 deletions(-) base-commit: f3ea8f7fa1d84a559c7bf834fe5b675abe0ae7b8 prerequisite-patch-id: 71184f71260952109165ec62c588c2b646e238f6 -- 2.38.1 From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 22 07:49:35 2022 Received: (at 52835) by debbugs.gnu.org; 22 Dec 2022 12:49:35 +0000 Received: from localhost ([127.0.0.1]:58193 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8L0w-0001c3-NQ for submit@debbugs.gnu.org; Thu, 22 Dec 2022 07:49:35 -0500 Received: from jpoiret.xyz ([206.189.101.64]:41548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8L0t-0001bb-LJ for 52835@debbugs.gnu.org; Thu, 22 Dec 2022 07:49:32 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 4E10B185316; Thu, 22 Dec 2022 12:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1671713370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yi0eZsNOSmpXzvPzihGMhAbkrRzqL2sKBtI+TnZoy6g=; b=KNJnkztoVfP4PTG5FG3LFWCMvvC6CUPo4dafkuoRdkklzLpoSYuUYTShJCaWkv5dalyGC6 SW9v4ZWMub1nkmv3/VTM3meC2mmW1shlvdXYtOw3+LMCBv5bLQzwLCTdL/JwUa8vYFI+ep WfSGE9kcEf2wSQ/yHWe/oCJ1Q+y05nUNqrV7+1gjXmJVJtuLg3PHzYqSVJCY8dfSj5/0Qx /qYpH2+npj33HnW4wR4VwJsLf3Fm1BhA7k54kPGbZ8l3nNpt0bQKxFDQTw6ebCkwAM4xPQ UmxDRxTTDdZ8H9fVSfrjhBpwutDV7ECuC5/IYbqI7OdBTM5eGD++73kTETxpqw== From: Josselin Poiret To: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v6 2/3] Make system* and piped-process internally use spawn. Date: Thu, 22 Dec 2022 13:49:09 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (scm_system_star, scm_piped_process): Use do_spawn. (start_child): Remove function. --- libguile/posix.c | 181 ++++++++++ 1 file changed, 39 ins [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample , Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) * libguile/posix.c (scm_system_star, scm_piped_process): Use do_spawn. (start_child): Remove function. --- libguile/posix.c | 181 ++++++++++------------------------------------- 1 file changed, 39 insertions(+), 142 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index e92625483..f9c36d7ac 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1308,125 +1308,6 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #undef FUNC_NAME #endif /* HAVE_FORK */ -#ifdef HAVE_FORK -/* 'renumber_file_descriptor' is a helper function for 'start_child' - below, and is specialized for that particular environment where it - doesn't make sense to report errors via exceptions. It uses dup(2) - to duplicate the file descriptor FD, closes the original FD, and - returns the new descriptor. If dup(2) fails, print an error message - to ERR and abort. */ -static int -renumber_file_descriptor (int fd, int err) -{ - int new_fd; - - do - new_fd = dup (fd); - while (new_fd == -1 && errno == EINTR); - - if (new_fd == -1) - { - /* At this point we are in the child process before exec. We - cannot safely raise an exception in this environment. */ - const char *msg = strerror (errno); - fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); - _exit (127); /* Use exit status 127, as with other exec errors. */ - } - - close (fd); - return new_fd; -} -#endif /* HAVE_FORK */ - -#ifdef HAVE_FORK -#define HAVE_START_CHILD 1 -/* Since Guile uses threads, we have to be very careful to avoid calling - functions that are not async-signal-safe in the child. That's why - this function is implemented in C. */ -static pid_t -start_child (const char *exec_file, char **exec_argv, - int reading, int c2p[2], int writing, int p2c[2], - int in, int out, int err) -{ - int pid; - int max_fd = 1024; - -#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) - { - struct rlimit lim = { 0, 0 }; - if (getrlimit (RLIMIT_NOFILE, &lim) == 0) - max_fd = lim.rlim_cur; - } -#endif - - pid = fork (); - - if (pid != 0) - /* The parent, with either and error (pid == -1), or the PID of the - child. Return directly in either case. */ - return pid; - - /* The child. */ - if (reading) - close (c2p[0]); - if (writing) - close (p2c[1]); - - /* Close all file descriptors in ports inherited from the parent - except for in, out, and err. Heavy-handed, but robust. */ - while (max_fd--) - if (max_fd != in && max_fd != out && max_fd != err) - close (max_fd); - - /* Ignore errors on these open() calls. */ - if (in == -1) - in = open ("/dev/null", O_RDONLY); - if (out == -1) - out = open ("/dev/null", O_WRONLY); - if (err == -1) - err = open ("/dev/null", O_WRONLY); - - if (in > 0) - { - if (out == 0) - out = renumber_file_descriptor (out, err); - if (err == 0) - err = renumber_file_descriptor (err, err); - do dup2 (in, 0); while (errno == EINTR); - close (in); - } - if (out > 1) - { - if (err == 1) - err = renumber_file_descriptor (err, err); - do dup2 (out, 1); while (errno == EINTR); - if (out > 2) - close (out); - } - if (err > 2) - { - do dup2 (err, 2); while (errno == EINTR); - close (err); - } - - execvp (exec_file, exec_argv); - - /* The exec failed! There is nothing sensible to do. */ - { - const char *msg = strerror (errno); - fprintf (fdopen (2, "a"), "In execvp of %s: %s\n", - exec_file, msg); - } - - /* Use exit status 127, like shells in this case, as per POSIX - . */ - _exit (127); - - /* Not reached. */ - return -1; -} -#endif - static int do_spawn (char *exec_file, char **exec_argv, char **exec_env, int in, int out, int err) { @@ -1507,7 +1388,7 @@ SCM_DEFINE (scm_spawn_process, "spawn*", 5, 0, 0, } #undef FUNC_NAME -#ifdef HAVE_START_CHILD +#ifdef HAVE_FORK static SCM scm_piped_process (SCM prog, SCM args, SCM from, SCM to) #define FUNC_NAME "piped-process" @@ -1519,6 +1400,7 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to) int pid; char *exec_file; char **exec_argv; + char **exec_env = environ; exec_file = scm_to_locale_string (prog); exec_argv = scm_i_allocate_string_pointers (scm_cons (prog, args)); @@ -1551,27 +1433,44 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to) in = SCM_FPORT_FDES (port); } - pid = start_child (exec_file, exec_argv, reading, c2p, writing, p2c, - in, out, err); + pid = do_spawn (exec_file, exec_argv, exec_env, in, out, err); + int errno_save = errno; if (pid == -1) { - int errno_save = errno; - free (exec_file); - if (reading) - { - close (c2p[0]); - close (c2p[1]); - } - if (writing) - { - close (p2c[0]); - close (p2c[1]); - } - errno = errno_save; - SCM_SYSERROR; + /* TODO This is a compatibility shim until the next major release */ + switch (errno) { + /* If the error seemingly comes from fork */ + case EAGAIN: + case ENOMEM: + case ENOSYS: + free (exec_file); + + if (reading) + { + close (c2p[0]); + } + if (writing) + { + close (p2c[1]); + } + errno = errno_save; + SCM_SYSERROR; + break; + /* Else create a dummy process that exits with value 127 */ + default: + dprintf (err, "In execvp of %s: %s\n", exec_file, + strerror (errno_save)); + pid = fork (); + if (pid == -1) + SCM_SYSERROR; + if (pid == 0) + _exit (127); + } } + free (exec_file); + if (reading) close (c2p[1]); if (writing) @@ -1651,7 +1550,7 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, return scm_from_int (status); } #undef FUNC_NAME -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ #ifdef HAVE_UNAME SCM_DEFINE (scm_uname, "uname", 0, 0, 0, @@ -2497,13 +2396,13 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0, #endif /* HAVE_GETHOSTNAME */ -#ifdef HAVE_START_CHILD +#ifdef HAVE_FORK static void scm_init_popen (void) { scm_c_define_gsubr ("piped-process", 2, 2, 0, scm_piped_process); } -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ void scm_init_posix () @@ -2621,12 +2520,10 @@ scm_init_posix () #ifdef HAVE_FORK scm_add_feature ("fork"); -#endif /* HAVE_FORK */ -#ifdef HAVE_START_CHILD scm_add_feature ("popen"); scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION, "scm_init_popen", (scm_t_extension_init_func) scm_init_popen, NULL); -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ } -- 2.38.1 From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 22 07:49:50 2022 Received: (at 52835) by debbugs.gnu.org; 22 Dec 2022 12:49:50 +0000 Received: from localhost ([127.0.0.1]:58196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8L1B-0001cW-OF for submit@debbugs.gnu.org; Thu, 22 Dec 2022 07:49:50 -0500 Received: from jpoiret.xyz ([206.189.101.64]:41712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8L0w-0001bt-5E for 52835@debbugs.gnu.org; Thu, 22 Dec 2022 07:49:35 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 2F0C0185319; Thu, 22 Dec 2022 12:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1671713373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZoJsoLY5htkd87/FUijme8Eo0+rsTcYELO/YqaEebh4=; b=qWKvP/ZOtdJ7+bhqM7HxfBRN8botve6s2dZPnomdgsNEd2GB6dNCLwaeiEQLeUfNMjXO65 I3bqTet79jNDv3QHdtQe0n4YVHPuhDCod4CXhBNCRVM2NcytJ9z/wsDixDHK1/ayoBVYfs 3/85o1vNX/uBWPZkBzD4i2Zdsnz60nnxV4/ZjMTMHikOclRpp5f2vouqllXVSZmPX1qgnx G2WRwumNf4l/ArI+g4+xNN1AUIyA6fz5AFM2Ot4ecA07hHZ5Ipd7pFlVP/zmbEAc4qB60g CM10a42/lhRTXeG7wS7IA9tlUuVfXViJt+A+UOsVARseQMeEJp4GDdjr63i6FQ== From: Josselin Poiret To: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v6 3/3] Move popen and posix procedures to spawn*. Date: Thu, 22 Dec 2022 13:49:10 +0100 Message-Id: <2423f06c9596dc05ab669247551b5b7bd7c134a0.1671710701.git.dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * libguile/posix.c (scm_piped_process, scm_init_popen): Remove functions. (scm_port_to_fd_with_default): New helper function. (scm_system_star): Rewrite using scm_spawn_process. (scm_init_popen): Remo [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample , Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) * libguile/posix.c (scm_piped_process, scm_init_popen): Remove functions. (scm_port_to_fd_with_default): New helper function. (scm_system_star): Rewrite using scm_spawn_process. (scm_init_popen): Remove the definition of piped-process. (scm_init_posix): Now make popen available unconditionally. * module/ice-9/popen.scm (port-with-defaults): New helper procedure. (spawn): New procedure. (open-process): Rewrite using spawn. (pipeline): Rewrite using spawn*. * test-suite/tests/popen.test ("piped-process", "piped-process: with-output"): Removed tests. ("spawn", "spawn: with output"): Added tests. * test-suite/tests/posix.test ("http://bugs.gnu.org/13166", "exit code for nonexistent file", "https://bugs.gnu.org/55596"): Remove obsolete tests. ("exception for nonexistent file"): Add test. --- libguile/posix.c | 144 ++++++++---------------------------- module/ice-9/popen.scm | 87 +++++++++++++++------- test-suite/tests/popen.test | 14 ++-- test-suite/tests/posix.test | 36 ++++----- 4 files changed, 118 insertions(+), 163 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index f9c36d7ac..1401a9118 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -64,6 +64,7 @@ #include "fports.h" #include "gettext.h" #include "gsubr.h" +#include "ioext.h" #include "list.h" #include "modules.h" #include "numbers.h" @@ -1388,98 +1389,6 @@ SCM_DEFINE (scm_spawn_process, "spawn*", 5, 0, 0, } #undef FUNC_NAME -#ifdef HAVE_FORK -static SCM -scm_piped_process (SCM prog, SCM args, SCM from, SCM to) -#define FUNC_NAME "piped-process" -{ - int reading, writing; - int c2p[2]; /* Child to parent. */ - int p2c[2]; /* Parent to child. */ - int in = -1, out = -1, err = -1; - int pid; - char *exec_file; - char **exec_argv; - char **exec_env = environ; - - exec_file = scm_to_locale_string (prog); - exec_argv = scm_i_allocate_string_pointers (scm_cons (prog, args)); - - reading = scm_is_pair (from); - writing = scm_is_pair (to); - - if (reading) - { - c2p[0] = scm_to_int (scm_car (from)); - c2p[1] = scm_to_int (scm_cdr (from)); - out = c2p[1]; - } - - if (writing) - { - p2c[0] = scm_to_int (scm_car (to)); - p2c[1] = scm_to_int (scm_cdr (to)); - in = p2c[0]; - } - - { - SCM port; - - if (SCM_OPOUTFPORTP ((port = scm_current_error_port ()))) - err = SCM_FPORT_FDES (port); - if (out == -1 && SCM_OPOUTFPORTP ((port = scm_current_output_port ()))) - out = SCM_FPORT_FDES (port); - if (in == -1 && SCM_OPINFPORTP ((port = scm_current_input_port ()))) - in = SCM_FPORT_FDES (port); - } - - pid = do_spawn (exec_file, exec_argv, exec_env, in, out, err); - int errno_save = errno; - - if (pid == -1) - { - /* TODO This is a compatibility shim until the next major release */ - switch (errno) { - /* If the error seemingly comes from fork */ - case EAGAIN: - case ENOMEM: - case ENOSYS: - free (exec_file); - - if (reading) - { - close (c2p[0]); - } - if (writing) - { - close (p2c[1]); - } - errno = errno_save; - SCM_SYSERROR; - break; - /* Else create a dummy process that exits with value 127 */ - default: - dprintf (err, "In execvp of %s: %s\n", exec_file, - strerror (errno_save)); - pid = fork (); - if (pid == -1) - SCM_SYSERROR; - if (pid == 0) - _exit (127); - } - } - - free (exec_file); - - if (reading) - close (c2p[1]); - if (writing) - close (p2c[0]); - - return scm_from_int (pid); -} -#undef FUNC_NAME - static void restore_sigaction (SCM pair) { @@ -1501,6 +1410,15 @@ scm_dynwind_sigaction (int sig, SCM handler, SCM flags) SCM_F_WIND_EXPLICITLY); } +static int +port_to_fd_with_default (SCM port, int mode) +{ + if (!SCM_FPORTP (port)) + return open_or_open64 ("/dev/null", mode); + return SCM_FPORT_FDES (port); + +} + SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, (SCM args), "Execute the command indicated by @var{args}. The first element must\n" @@ -1521,13 +1439,14 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, "Example: (system* \"echo\" \"foo\" \"bar\")") #define FUNC_NAME s_scm_system_star { - SCM prog, pid; - int status, wait_result; + int pid, status, wait_result; + + int in, out, err; + char *exec_file; + char **exec_argv; if (scm_is_null (args)) SCM_WRONG_NUM_ARGS (); - prog = scm_car (args); - args = scm_cdr (args); scm_dynwind_begin (0); /* Make sure the child can't kill us (as per normal system call). */ @@ -1540,8 +1459,23 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, SCM_UNDEFINED); #endif - pid = scm_piped_process (prog, args, SCM_UNDEFINED, SCM_UNDEFINED); - SCM_SYSCALL (wait_result = waitpid (scm_to_int (pid), &status, 0)); + exec_file = scm_to_locale_string (scm_car (args)); + exec_argv = scm_i_allocate_string_pointers (args); + + in = port_to_fd_with_default (scm_current_input_port (), O_RDONLY); + out = port_to_fd_with_default (scm_current_output_port (), O_WRONLY); + err = port_to_fd_with_default (scm_current_error_port (), O_WRONLY); + + pid = do_spawn (exec_file, exec_argv, environ, in, out, err); + if (pid == -1) + { + int errno_save = errno; + free (exec_file); + errno = errno_save; + SCM_SYSERROR; + } + + SCM_SYSCALL (wait_result = waitpid (pid, &status, 0)); if (wait_result == -1) SCM_SYSERROR; @@ -1550,7 +1484,6 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, return scm_from_int (status); } #undef FUNC_NAME -#endif /* HAVE_FORK */ #ifdef HAVE_UNAME SCM_DEFINE (scm_uname, "uname", 0, 0, 0, @@ -2396,14 +2329,6 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0, #endif /* HAVE_GETHOSTNAME */ -#ifdef HAVE_FORK -static void -scm_init_popen (void) -{ - scm_c_define_gsubr ("piped-process", 2, 2, 0, scm_piped_process); -} -#endif /* HAVE_FORK */ - void scm_init_posix () { @@ -2520,10 +2445,5 @@ scm_init_posix () #ifdef HAVE_FORK scm_add_feature ("fork"); - scm_add_feature ("popen"); - scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION, - "scm_init_popen", - (scm_t_extension_init_func) scm_init_popen, - NULL); #endif /* HAVE_FORK */ } diff --git a/module/ice-9/popen.scm b/module/ice-9/popen.scm index e638726a4..547f56d5f 100644 --- a/module/ice-9/popen.scm +++ b/module/ice-9/popen.scm @@ -25,11 +25,34 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:export (port/pid-table open-pipe* open-pipe close-pipe open-input-pipe - open-output-pipe open-input-output-pipe pipeline)) + open-output-pipe open-input-output-pipe pipeline spawn)) -(eval-when (expand load eval) - (load-extension (string-append "libguile-" (effective-version)) - "scm_init_popen")) +(define (port-with-defaults port default-mode) + (if (file-port? port) + port + (open-file "/dev/null" default-mode))) + +(define* (spawn exec-file argv #:key + (in (current-input-port)) + (out (current-output-port)) + (err (current-error-port))) + "Spawns a new child process executing @var{prog} with arguments +@var{args}, with its standard input, output and error file descriptors +set to @var{in}, @var{out}, @var{err}." + (let* ((in (port-with-defaults in "r")) + (out (port-with-defaults out "w")) + (err (port-with-defaults err "w")) + ;; Increment port revealed counts while to prevent ports GC'ing and + ;; closing the associated fds while we spawn the process. + (result (spawn* exec-file + argv + (port->fdes in) + (port->fdes out) + (port->fdes err)))) + (release-port-handle in) + (release-port-handle out) + (release-port-handle err) + result)) (define-record-type (make-pipe-info pid) @@ -92,13 +115,13 @@ (define (open-process mode command . args) "Backwards compatible implementation of the former procedure in -libguile/posix.c (scm_open_process) replaced by -scm_piped_process. Executes the program @var{command} with optional -arguments @var{args} (all strings) in a subprocess. A port to the -process (based on pipes) is created and returned. @var{mode} specifies -whether an input, an output or an input-output port to the process is -created: it should be the value of @code{OPEN_READ}, @code{OPEN_WRITE} -or @code{OPEN_BOTH}." +libguile/posix.c (scm_open_process) replaced by scm_piped_process, now +replaced by scm_spawn_process. Executes the program @var{command} with +optional arguments @var{args} (all strings) in a subprocess. A port to +the process (based on pipes) is created and returned. @var{mode} +specifies whether an input, an output or an input-output port to the +process is created: it should be the value of @code{OPEN_READ}, +@code{OPEN_WRITE} or @code{OPEN_BOTH}." (define (unbuffered port) (setvbuf port 'none) port) @@ -107,19 +130,25 @@ or @code{OPEN_BOTH}." (and ports (cons (port->fdes (car ports)) (port->fdes (cdr ports))))) - (let* ((from (and (or (string=? mode OPEN_READ) - (string=? mode OPEN_BOTH)) - (pipe))) - (to (and (or (string=? mode OPEN_WRITE) - (string=? mode OPEN_BOTH)) - (pipe))) - (pid (piped-process command args - (fdes-pair from) - (fdes-pair to)))) + (let* ((child-to-parent (and (or (string=? mode OPEN_READ) + (string=? mode OPEN_BOTH)) + (pipe))) + (parent-to-child (and (or (string=? mode OPEN_WRITE) + (string=? mode OPEN_BOTH)) + (pipe))) + (in (or (and=> parent-to-child car) (current-input-port))) + (out (or (and=> child-to-parent cdr) (current-output-port))) + (pid (spawn command (cons command args) + #:in in + #:out out))) + (when child-to-parent + (close (cdr child-to-parent))) + (when parent-to-child + (close (car parent-to-child))) ;; The original 'open-process' procedure would return unbuffered ;; ports; do the same here. - (values (and from (unbuffered (car from))) - (and to (unbuffered (cdr to))) + (values (and child-to-parent (unbuffered (car child-to-parent))) + (and parent-to-child (unbuffered (cdr parent-to-child))) pid))) (define (open-pipe* mode command . args) @@ -224,10 +253,16 @@ a list of PIDs of the processes executing the @var{commands}." (pipeline (fold (lambda (from proc prev) (let* ((to (car prev)) (pids (cdr prev)) - (pid (piped-process (car proc) - (cdr proc) - from - to))) + (pid (spawn* (car proc) + proc + (car to) + (cdr from) + (port->fdes + (port-with-defaults + (current-error-port) + "w"))))) + (close-fdes (car to)) + (close-fdes (cdr from)) (cons from (cons pid pids)))) `(,to) pipes diff --git a/test-suite/tests/popen.test b/test-suite/tests/popen.test index 3df863375..fd810e376 100644 --- a/test-suite/tests/popen.test +++ b/test-suite/tests/popen.test @@ -257,18 +257,18 @@ exec 2>~a; read REPLY" (list (read-string from) (status:exit-val (cdr (waitpid pid)))))) -(pass-if-equal "piped-process" +(pass-if-equal "spawn" 42 (status:exit-val - (cdr (waitpid ((@@ (ice-9 popen) piped-process) - "./meta/guile" '("-c" "(exit 42)")))))) + (cdr (waitpid (spawn + "./meta/guile" '("./meta/guile" "-c" "(exit 42)")))))) -(pass-if-equal "piped-process: with output" +(pass-if-equal "spawn: with output" '("foo bar\n" 0) (let* ((p (pipe)) - (pid ((@@ (ice-9 popen) piped-process) "echo" '("foo" "bar") - (cons (port->fdes (car p)) - (port->fdes (cdr p)))))) + (pid (spawn "echo" '("echo" "foo" "bar") + #:out (cdr p)))) + (close (cdr p)) (list (read-string (car p)) (status:exit-val (cdr (waitpid pid)))))) diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test index bfc6f168e..5c971f4f7 100644 --- a/test-suite/tests/posix.test +++ b/test-suite/tests/posix.test @@ -340,24 +340,24 @@ (with-test-prefix "system*" - (pass-if "http://bugs.gnu.org/13166" - ;; With Guile up to 2.0.7 included, the child process launched by - ;; `system*' would remain alive after an `execvp' failure. - (let ((me (getpid))) - (and (not (zero? (system* "something-that-does-not-exist"))) - (= me (getpid))))) - - (pass-if-equal "exit code for nonexistent file" - 127 ;aka. EX_NOTFOUND - (status:exit-val (system* "something-that-does-not-exist"))) - - (pass-if-equal "https://bugs.gnu.org/55596" - 127 - ;; The parameterization below used to cause 'start_child' to close - ;; fd 2 in the child process, which in turn would cause it to - ;; segfault, leading to a wrong exit code. - (parameterize ((current-output-port (current-error-port))) - (status:exit-val (system* "something-that-does-not-exist"))))) + (pass-if-equal "exception for nonexistent file" + 2 ; ENOENT + (call-with-prompt 'escape + (lambda () + (with-exception-handler + (lambda (exn) + (let* ((kind (exception-kind exn)) + (errno (and (eq? kind 'system-error) + (car (car + (cdr (cdr (cdr (exception-args + exn))))))))) + (abort-to-prompt 'escape errno))) + (lambda () + (status:exit-val (system* + "something-that-does-not-exist"))) + #:unwind? #t)) + (lambda (k arg) + arg)))) ;; ;; crypt -- 2.38.1 From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 23 05:53:39 2022 Received: (at 52835) by debbugs.gnu.org; 23 Dec 2022 10:53:39 +0000 Received: from localhost ([127.0.0.1]:36928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8fgJ-00006o-B5 for submit@debbugs.gnu.org; Fri, 23 Dec 2022 05:53:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8fgG-00006f-SS for 52835@debbugs.gnu.org; Fri, 23 Dec 2022 05:53:37 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8fgA-0003wE-Ro; Fri, 23 Dec 2022 05:53:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=zQ1V9kemSuY6s3ktuQpdDIg64BrRHd++BHYXYEdmTmQ=; b=DF1krITYHbQxaxK3KyV4 rewmlVBvbRnWjxBzUd3gOxSn6tHCJ4peyDw8iTgOLsluxRtfaItivOfFBuCWXniLZCPSx989xeAbJ xqzr6Ma3A6vIDQNu5A4hMwqHch7V1ibksbT2JtzGJSrPcrMa7YN0o7zxxycv2+h74j5R9G9E3Fju3 uszYofareCaQcBiMmxvsRPWPrKALeoNlpw76OPqGjauekMn8TPEUdAvc7lKKskq+MAc5QeEvJ+qMa Qn6i3/bdT2V1sNfz7kmbCxyCHDHCb7Gcg6dttPyRM+Qc8ESlxZ2NdNqYeeuOx/nz8KfdPvVxA9K4P wePlIGoBwiyF+Q==; Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8fg9-0006Wg-F5; Fri, 23 Dec 2022 05:53:29 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Josselin Poiret Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: <87iligyyh9.fsf@gnu.org> Date: Fri, 23 Dec 2022 11:53:26 +0100 In-Reply-To: (Josselin Poiret's message of "Thu, 22 Dec 2022 13:49:07 +0100") Message-ID: <87y1qyz909.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Josselin, Josselin Poiret skribis: > Here is hopefully the last reroll of this patchset. First of all, I did = not > include the gnulib patch again because it still applies cleanly and it is > extremely large, but it should be applied before those 3 patches. Yay! > The first two patches should be applied on the current major release, whi= le the > third one should be applied on the next major release to finish the migra= tion to > spawn. I pushed it to =E2=80=98wip-posix-spawn=E2=80=99 along with fixups I=E2=80= =99m proposing, mostly along the lines of what I suggested in : =E2=80=A2 Avoiding the extra =E2=80=98fork=E2=80=99 in =E2=80=98system*= =E2=80=99 upon error; =E2=80=A2 Keep =E2=80=98scm_spawn_process=E2=80=99 internal. I also added Andrew Whatson=E2=80=99s patch from . If that=E2=80=99s fine with you, I can squash the =E2=80=9Cfixup!=E2=80=9D = commits and merge the branch. Let me know! Earlier we agreed it=E2=80=99d be nice to expose =E2=80=98spawn*=E2=80=99/= =E2=80=98primitive-spawn=E2=80=99. I still think it=E2=80=99s a good idea, but the interface would need some wor= k IMO to be more generally useful. In essence, we could provide something similar to =E2=80=98fork+exec-command=E2=80=99 in the Shepherd, where one c= an pass environment variables, stdin/stdout/stderr, etc., all that with keyword arguments and reasonable defaults. It=E2=80=99s a bit of extra work though so we can discuss that later, separately. Thank you! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 23 12:15:08 2022 Received: (at 52835) by debbugs.gnu.org; 23 Dec 2022 17:15:08 +0000 Received: from localhost ([127.0.0.1]:37837 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8ldU-0007Sy-64 for submit@debbugs.gnu.org; Fri, 23 Dec 2022 12:15:08 -0500 Received: from jpoiret.xyz ([206.189.101.64]:45090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8ldS-0007Ss-Bh for 52835@debbugs.gnu.org; Fri, 23 Dec 2022 12:15:06 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 584AD184D6B; Fri, 23 Dec 2022 17:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1671815704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+rE6qyxo7X0e8NZffIm9MP0HhW9dHLS9+F/SSC46OMA=; b=ELdA5GMBq+/H+qwP7pJA+/hxnwNsbebfIEhdOYv8mxt0fbhBw9ILRtBnJ4iOv9/912I+eX 1GwgXpjcI3y3Pi04PXFMaEXL06dDQg6tJkf00Z8SzIJCGZvEpwGfOhL1ZVBvY2oVKDZDd8 xaOl66vNrWOtPB2PXGvYUk4RzSgtCkt2kYhYhYtoyno0Aq1+zADsbHn9WBiK4SGSWuZf1C UkXdudDpMwS8qsZ0z1W0E4JWhGUuvQjh9RtZxDrgmkYaEwqXnG7/oTcystOoqHIiTmrmK6 E7wECO9+Tc5I7kX+Zvs8mj1eQseZOpBmhjr2BXIg74r/7PWKr1d6IGilXYnhNQ== From: Josselin Poiret To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly In-Reply-To: <87y1qyz909.fsf_-_@gnu.org> References: <87iligyyh9.fsf@gnu.org> <87y1qyz909.fsf_-_@gnu.org> Date: Fri, 23 Dec 2022 18:15:03 +0100 Message-ID: <87v8m2jb3c.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Ludo, thanks for the quick review and fixes. > I pushed it to =E2=80=98wip-posix-spawn=E2=80=99 along with fixups I=E2= =80=99m proposing, mostly > along the lines of what I suggested in > : Nice but also see below. > I also added Andrew Whatson=E2=80=99s patch from > . Great, hadn't see that one go by! > If that=E2=80=99s fine with you, I can squash the =E2=80=9Cfixup!=E2=80= =9D commits and merge the > branch. Let me know! > > Earlier we agreed it=E2=80=99d be nice to expose =E2=80=98spawn*=E2=80=99= /=E2=80=98primitive-spawn=E2=80=99. I > still think it=E2=80=99s a good idea, but the interface would need some w= ork IMO > to be more generally useful. In essence, we could provide something > similar to =E2=80=98fork+exec-command=E2=80=99 in the Shepherd, where one= can pass > environment variables, stdin/stdout/stderr, etc., all that with keyword > arguments and reasonable defaults. I've just polished it up a bit: the `spawn*` procedure defined in C now takes another argument, a list of environment variables. I think this interface is good enough to cover most use cases, if anyone needs something more complicated they should go through their own C code. I've added a convenience module (ice-9 spawn) with a `spawn` procedure in it, which takes an optional argument list which defaults to just the executable, and optional environment variables as well as in, out and err ports. I also think everything in (ice-9 popen) should be migrated on the next major release, as well as being re-implemented in terms of `spawn` purely, so that the change is immediately noticeable. We're reaching the bike-shedding time now, but IMHO having such a `spawn*` exposed to the user seems fine, it's a pretty simple "raw" interface with fdes, and there is a convenience `spawn` function that is nicer for users. Do we need to add a documentation page as well? Best, --=20 Josselin Poiret From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 23 12:17:12 2022 Received: (at 52835) by debbugs.gnu.org; 23 Dec 2022 17:17:12 +0000 Received: from localhost ([127.0.0.1]:37849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8lfT-0007Uc-NA for submit@debbugs.gnu.org; Fri, 23 Dec 2022 12:17:12 -0500 Received: from jpoiret.xyz ([206.189.101.64]:45368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8lfR-0007UV-Lx for 52835@debbugs.gnu.org; Fri, 23 Dec 2022 12:17:10 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id B34C0184D6B; Fri, 23 Dec 2022 17:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1671815829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nQyELhx1kZno8MJGBjzGFvn/A6ER4i6BfcTTqqGqvY4=; b=VXWIORlLDXk8bnOnpnf68wB8tLAgAm6AeAQ9JL26EVWuF+ikS9yJ538VlgL4wuDoYgmn50 BzScPLupjdAr9txGeXyonCbqE/uRcBPlhclzAisJLBOaL4gXIRmHsN05xj+QqVI//KcDPa 6BF5futI4+Oy+QAZe2FM7/5Q9klCgNAJEcOccurhvfnQL0p3s+RuGyeJj0O2QjWN+Jz/yU ZWTvOYqmaDAhJnMV1O/hOYPIhrktMQDf16QOSUP/FaG9aUpClF6oIqIKmXNR9lzQ0liq7g WW4HhfLIHEhXfZn6FCrR48K8uQjCZt6VbnHL4PlfUBAiLzN+ApqBUGsFY1wxgA== From: Josselin Poiret To: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v7 1/2] Add spawn* and spawn. Date: Fri, 23 Dec 2022 18:17:05 +0100 Message-Id: <388cbca36850d1837b3c478d9bd9dd5e222215b0.1671815759.git.dev@jpoiret.xyz> In-Reply-To: <87v8m2jb3c.fsf@jpoiret.xyz> References: <87v8m2jb3c.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * libguile/posix.c: Include spawn.h from Gnulib. (do_spawn, scm_spawn_process): New functions. * module/ice-9/spawn.scm: New file (spawn): New procedure. --- libguile/posix.c | 82 ++++++++++++++++++++++++++++++++++++++++++ libguile/posix.h | 2 ++ module/ice-9/spawn.scm | 54 ++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 module/ice-9/spawn.scm diff --git a/libguile/posix.c b/libguile/posix.c index b5352c2c4..52dc11e57 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef HAVE_SCHED_H # include @@ -1426,6 +1427,87 @@ start_child (const char *exec_file, char **exec_argv, } #endif +static pid_t +do_spawn (char *exec_file, char **exec_argv, char **exec_env, int in, int out, int err) +{ + pid_t pid = -1; + + posix_spawn_file_actions_t actions; + posix_spawnattr_t *attrp = NULL; + + int max_fd = 1024; + +#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) + { + struct rlimit lim = { 0, 0 }; + if (getrlimit (RLIMIT_NOFILE, &lim) == 0) + max_fd = lim.rlim_cur; + } +#endif + + posix_spawn_file_actions_init (&actions); + + int free_fd_slots = 0; + int fd_slot[3]; + + for (int fdnum = 3;free_fd_slots < 3 && fdnum < max_fd;fdnum++) + { + if (fdnum != in && fdnum != out && fdnum != err) + { + fd_slot[free_fd_slots] = fdnum; + free_fd_slots++; + } + } + + /* Move the fds out of the way, so that duplicate fds or fds equal + to 0, 1, 2 don't trample each other */ + + posix_spawn_file_actions_adddup2 (&actions, in, fd_slot[0]); + posix_spawn_file_actions_adddup2 (&actions, out, fd_slot[1]); + posix_spawn_file_actions_adddup2 (&actions, err, fd_slot[2]); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[0], 0); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[1], 1); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[2], 2); + + while (--max_fd > 2) + posix_spawn_file_actions_addclose (&actions, max_fd); + + if (posix_spawnp (&pid, exec_file, &actions, attrp, exec_argv, exec_env) != 0) + return -1; + + return pid; +} + +SCM_DEFINE (scm_spawn_process, "spawn*", 6, 0, 0, + (SCM prog, SCM args, SCM env, SCM in, SCM out, SCM err), + "Spawns a new child process executing @var{prog} with arguments\n" + "@var{args}, with its standard input, output and error file descriptors\n" + "set to @var{in}, @var{out}, @var{err}, and environment to @var{env}.") +#define FUNC_NAME s_scm_spawn_process +{ + int pid; + char *exec_file; + char **exec_argv; + char **exec_env; + + exec_file = scm_to_locale_string (prog); + exec_argv = scm_i_allocate_string_pointers (args); + exec_env = scm_i_allocate_string_pointers (env); + + pid = do_spawn (exec_file, exec_argv, exec_env, + scm_to_int (in), + scm_to_int (out), + scm_to_int (err)); + + free (exec_file); + + if (pid == -1) + SCM_SYSERROR; + + return scm_from_int (pid); +} +#undef FUNC_NAME + #ifdef HAVE_START_CHILD static SCM scm_piped_process (SCM prog, SCM args, SCM from, SCM to) diff --git a/libguile/posix.h b/libguile/posix.h index 6504eaea8..35c502bc1 100644 --- a/libguile/posix.h +++ b/libguile/posix.h @@ -69,6 +69,8 @@ SCM_API SCM scm_tmpnam (void); SCM_API SCM scm_tmpfile (void); SCM_API SCM scm_open_pipe (SCM pipestr, SCM modes); SCM_API SCM scm_close_pipe (SCM port); +SCM_API SCM scm_spawn_process (SCM prog, SCM args, SCM env, + SCM in, SCM out, SCM err); SCM_API SCM scm_system_star (SCM cmds); SCM_API SCM scm_utime (SCM object, SCM actime, SCM modtime, SCM actimens, SCM modtimens, SCM flags); diff --git a/module/ice-9/spawn.scm b/module/ice-9/spawn.scm new file mode 100644 index 000000000..ae4f54efa --- /dev/null +++ b/module/ice-9/spawn.scm @@ -0,0 +1,54 @@ +;; Spawning programs + +;;;; Copyright (C) 2022 +;;;; Free Software Foundation, Inc. +;;;; +;;;; This 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 3 of the License, or (at your option) any later version. +;;;; +;;;; This 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 this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +(define-module (ice-9 spawn) + #:export (spawn)) + +(define (port-with-defaults port default-mode) + (if (file-port? port) + port + (open-file "/dev/null" default-mode))) + +(define* (spawn exec-file + #:optional (args (list exec-file)) + #:key (env (environ)) + (in (current-input-port)) + (out (current-output-port)) + (err (current-error-port))) + "Spawns a new process running the program @var{exec} with arguments +@var{args}, in the environment specified by the list of environment +variable strings @var{env}, and with standard input, output and error +set to the ports specified by @var{in}, @var{out}, @var{err}. Note that +the last part only works with fd-backed ports." + (let* ((in (port-with-defaults in "r")) + (out (port-with-defaults out "w")) + (err (port-with-defaults err "w")) + ;; Increment port revealed counts while to prevent ports GC'ing and + ;; closing the associated fds while we spawn the process. + (result (spawn* exec-file + args + env + (port->fdes in) + (port->fdes out) + (port->fdes err)))) + (release-port-handle in) + (release-port-handle out) + (release-port-handle err) + result)) base-commit: 4711d45176e9b75cef43699ed514669276af62fe -- 2.38.1 From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 23 12:17:19 2022 Received: (at 52835) by debbugs.gnu.org; 23 Dec 2022 17:17:20 +0000 Received: from localhost ([127.0.0.1]:37853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8lfb-0007Uo-8q for submit@debbugs.gnu.org; Fri, 23 Dec 2022 12:17:19 -0500 Received: from jpoiret.xyz ([206.189.101.64]:45458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8lfT-0007Ub-My for 52835@debbugs.gnu.org; Fri, 23 Dec 2022 12:17:12 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 10767185305; Fri, 23 Dec 2022 17:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1671815830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r4CqMBTLJYxdwHV9AA224MLf0fYTT1s+SudjolhQn+U=; b=NyMnb4dM9wEwUxZiKce7uHpQkr/50u3gewRQnh4VdxMNLc8G2LakmtyXWlhwf/5Nk2JYlp VztvFElU6HaZ7RuKeYTZvfINKVdEOSQgFPgI3SPZoiOFnXviwnDY6McCfCM3tsLWYtNSIE qJo+kkCzKfAo+pjseb+IMoVY3FbOI9ON6amz9n6RUlzwSGJZ3wT4xRQA/C5n1OBqT6oTsc nZUi8Nyju1SWo+uCOkQerl31aANuWBIwJF3+PmXQ4IRPirMg0ITVy1FVbZ8GmmGgeRhlT8 h0i+disFMbjDjYDba9TegytkEMuELx2cqQRUHTyn7wo+NE0PM0VEn5UJMP0LIw== From: Josselin Poiret To: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v7 2/2] Make system* and piped-process internally use spawn. Date: Fri, 23 Dec 2022 18:17:06 +0100 Message-Id: In-Reply-To: <388cbca36850d1837b3c478d9bd9dd5e222215b0.1671815759.git.dev@jpoiret.xyz> References: <388cbca36850d1837b3c478d9bd9dd5e222215b0.1671815759.git.dev@jpoiret.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: --- X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * libguile/posix.c (scm_system_star, scm_piped_process): Use do_spawn. (start_child): Remove function. Co-authored-by: Ludovic Courtès --- libguile/posix.c | 233 ++++++++++++++++------------------------------- 1 file changed, 78 insertions(+), 155 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 52dc11e57..ecc2b186e 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -77,6 +77,7 @@ #include "threads.h" #include "values.h" #include "vectors.h" +#include "verify.h" #include "version.h" #if (SCM_ENABLE_DEPRECATED == 1) @@ -95,6 +96,13 @@ # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif +#ifndef W_EXITCODE +/* Macro for constructing a status value. Found in glibc. */ +# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) +#endif +verify (WEXITSTATUS (W_EXITCODE (127, 0)) == 127); + + #include #ifdef HAVE_GRP_H @@ -1308,125 +1316,6 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #undef FUNC_NAME #endif /* HAVE_FORK */ -#ifdef HAVE_FORK -/* 'renumber_file_descriptor' is a helper function for 'start_child' - below, and is specialized for that particular environment where it - doesn't make sense to report errors via exceptions. It uses dup(2) - to duplicate the file descriptor FD, closes the original FD, and - returns the new descriptor. If dup(2) fails, print an error message - to ERR and abort. */ -static int -renumber_file_descriptor (int fd, int err) -{ - int new_fd; - - do - new_fd = dup (fd); - while (new_fd == -1 && errno == EINTR); - - if (new_fd == -1) - { - /* At this point we are in the child process before exec. We - cannot safely raise an exception in this environment. */ - const char *msg = strerror (errno); - fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); - _exit (127); /* Use exit status 127, as with other exec errors. */ - } - - close (fd); - return new_fd; -} -#endif /* HAVE_FORK */ - -#ifdef HAVE_FORK -#define HAVE_START_CHILD 1 -/* Since Guile uses threads, we have to be very careful to avoid calling - functions that are not async-signal-safe in the child. That's why - this function is implemented in C. */ -static pid_t -start_child (const char *exec_file, char **exec_argv, - int reading, int c2p[2], int writing, int p2c[2], - int in, int out, int err) -{ - int pid; - int max_fd = 1024; - -#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) - { - struct rlimit lim = { 0, 0 }; - if (getrlimit (RLIMIT_NOFILE, &lim) == 0) - max_fd = lim.rlim_cur; - } -#endif - - pid = fork (); - - if (pid != 0) - /* The parent, with either and error (pid == -1), or the PID of the - child. Return directly in either case. */ - return pid; - - /* The child. */ - if (reading) - close (c2p[0]); - if (writing) - close (p2c[1]); - - /* Close all file descriptors in ports inherited from the parent - except for in, out, and err. Heavy-handed, but robust. */ - while (max_fd--) - if (max_fd != in && max_fd != out && max_fd != err) - close (max_fd); - - /* Ignore errors on these open() calls. */ - if (in == -1) - in = open ("/dev/null", O_RDONLY); - if (out == -1) - out = open ("/dev/null", O_WRONLY); - if (err == -1) - err = open ("/dev/null", O_WRONLY); - - if (in > 0) - { - if (out == 0) - out = renumber_file_descriptor (out, err); - if (err == 0) - err = renumber_file_descriptor (err, err); - do dup2 (in, 0); while (errno == EINTR); - close (in); - } - if (out > 1) - { - if (err == 1) - err = renumber_file_descriptor (err, err); - do dup2 (out, 1); while (errno == EINTR); - if (out > 2) - close (out); - } - if (err > 2) - { - do dup2 (err, 2); while (errno == EINTR); - close (err); - } - - execvp (exec_file, exec_argv); - - /* The exec failed! There is nothing sensible to do. */ - { - const char *msg = strerror (errno); - fprintf (fdopen (2, "a"), "In execvp of %s: %s\n", - exec_file, msg); - } - - /* Use exit status 127, like shells in this case, as per POSIX - . */ - _exit (127); - - /* Not reached. */ - return -1; -} -#endif - static pid_t do_spawn (char *exec_file, char **exec_argv, char **exec_env, int in, int out, int err) { @@ -1508,18 +1397,18 @@ SCM_DEFINE (scm_spawn_process, "spawn*", 6, 0, 0, } #undef FUNC_NAME -#ifdef HAVE_START_CHILD -static SCM -scm_piped_process (SCM prog, SCM args, SCM from, SCM to) +#ifdef HAVE_FORK +static int +piped_process (pid_t *pid, SCM prog, SCM args, SCM from, SCM to) #define FUNC_NAME "piped-process" { int reading, writing; int c2p[2]; /* Child to parent. */ int p2c[2]; /* Parent to child. */ int in = -1, out = -1, err = -1; - int pid; char *exec_file; char **exec_argv; + char **exec_env = environ; exec_file = scm_to_locale_string (prog); exec_argv = scm_i_allocate_string_pointers (scm_cons (prog, args)); @@ -1552,32 +1441,57 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to) in = SCM_FPORT_FDES (port); } - pid = start_child (exec_file, exec_argv, reading, c2p, writing, p2c, - in, out, err); - - if (pid == -1) - { - int errno_save = errno; - free (exec_file); - if (reading) - { - close (c2p[0]); - close (c2p[1]); - } - if (writing) - { - close (p2c[0]); - close (p2c[1]); - } - errno = errno_save; - SCM_SYSERROR; - } + *pid = do_spawn (exec_file, exec_argv, exec_env, in, out, err); + int errno_save = (*pid < 0) ? errno : 0; if (reading) close (c2p[1]); if (writing) close (p2c[0]); + if (*pid == -1) + switch (errno_save) + { + /* Errors that seemingly come from fork. */ + case EAGAIN: + case ENOMEM: + case ENOSYS: + errno = err; + free (exec_file); + SCM_SYSERROR; + break; + + default: /* ENOENT, etc. */ + /* Create a dummy process that exits with value 127. */ + dprintf (err, "In execvp of %s: %s\n", exec_file, + strerror (errno_save)); + } + + free (exec_file); + + return errno_save; +} +#undef FUNC_NAME + +static SCM +scm_piped_process (SCM prog, SCM args, SCM from, SCM to) +#define FUNC_NAME "piped-process" +{ + pid_t pid; + + (void) piped_process (&pid, prog, args, from, to); + if (pid == -1) + { + /* Create a dummy process that exits with value 127 to mimic the + previous fork + exec implementation. TODO: This is a + compatibility shim to remove in the next stable series. */ + pid = fork (); + if (pid == -1) + SCM_SYSERROR; + if (pid == 0) + _exit (127); + } + return scm_from_int (pid); } #undef FUNC_NAME @@ -1623,8 +1537,9 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, "Example: (system* \"echo\" \"foo\" \"bar\")") #define FUNC_NAME s_scm_system_star { - SCM prog, pid; - int status, wait_result; + SCM prog; + pid_t pid; + int err, status, wait_result; if (scm_is_null (args)) SCM_WRONG_NUM_ARGS (); @@ -1642,17 +1557,27 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, SCM_UNDEFINED); #endif - pid = scm_piped_process (prog, args, SCM_UNDEFINED, SCM_UNDEFINED); - SCM_SYSCALL (wait_result = waitpid (scm_to_int (pid), &status, 0)); - if (wait_result == -1) - SCM_SYSERROR; + err = piped_process (&pid, prog, args, + SCM_UNDEFINED, SCM_UNDEFINED); + if (err != 0) + /* ERR might be ENOENT or similar. For backward compatibility with + the previous implementation based on fork + exec, pretend the + child process exited with code 127. TODO: Remove this + compatibility shim in the next stable series. */ + status = W_EXITCODE (127, 0); + else + { + SCM_SYSCALL (wait_result = waitpid (pid, &status, 0)); + if (wait_result == -1) + SCM_SYSERROR; + } scm_dynwind_end (); return scm_from_int (status); } #undef FUNC_NAME -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ #ifdef HAVE_UNAME SCM_DEFINE (scm_uname, "uname", 0, 0, 0, @@ -2498,13 +2423,13 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0, #endif /* HAVE_GETHOSTNAME */ -#ifdef HAVE_START_CHILD +#ifdef HAVE_FORK static void scm_init_popen (void) { scm_c_define_gsubr ("piped-process", 2, 2, 0, scm_piped_process); } -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ void scm_init_posix () @@ -2622,12 +2547,10 @@ scm_init_posix () #ifdef HAVE_FORK scm_add_feature ("fork"); -#endif /* HAVE_FORK */ -#ifdef HAVE_START_CHILD scm_add_feature ("popen"); scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION, "scm_init_popen", (scm_t_extension_init_func) scm_init_popen, NULL); -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ } -- 2.38.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 25 11:58:13 2022 Received: (at 52835) by debbugs.gnu.org; 25 Dec 2022 16:58:13 +0000 Received: from localhost ([127.0.0.1]:50033 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9UKD-0006Ly-GD for submit@debbugs.gnu.org; Sun, 25 Dec 2022 11:58:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9UKB-0006Le-Kr for 52835@debbugs.gnu.org; Sun, 25 Dec 2022 11:58:12 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9UK5-0002iK-SB; Sun, 25 Dec 2022 11:58:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=sIZAlX2uPPsRGQ5leOA2SmgW9kgJXJlb0L0qHJ1RgIE=; b=kuHIO+dkLwk6MKUq9TqT VvHGtayKHuR3Jv3kGID5Ntsz6x/3JGFun/RP6AokggcDdV8hYC0HOaU2HMCUYZnGvFewmO3YNTsmz OsZ1Ub/nTslbY5oJs2AeqCPaEGW02EuYOaDwupt/ybYjMlpFAH9EZWLZr/TnwYC64jNZ2KMOf59Md WZY7jYZwmzwo1uYDCOXoSbetb4MebSthJoqXBvuG+V54e71gFrS7yoW+niEFBxW9IPmosfytBgCR8 RZjHvi3OfGGoA0p6Oak5W8CCFBxDsLKpumB7bWPcAxCBjtjxalwNWmVf1AXtWcWY5FMgTL/vTAb+Z GGLaO4w/NNOY2Q==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9UK5-0005Pn-9a; Sun, 25 Dec 2022 11:58:05 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Josselin Poiret Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: <87iligyyh9.fsf@gnu.org> <87y1qyz909.fsf_-_@gnu.org> <87v8m2jb3c.fsf@jpoiret.xyz> Date: Sun, 25 Dec 2022 17:58:02 +0100 In-Reply-To: <87v8m2jb3c.fsf@jpoiret.xyz> (Josselin Poiret's message of "Fri, 23 Dec 2022 18:15:03 +0100") Message-ID: <87a63bxvxh.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Josselin, Josselin Poiret skribis: > I've added a convenience module (ice-9 spawn) with a `spawn` procedure > in it, which takes an optional argument list which defaults to just the > executable, and optional environment variables as well as in, out and > err ports. I also think everything in (ice-9 popen) should be migrated > on the next major release, as well as being re-implemented in terms of > `spawn` purely, so that the change is immediately noticeable. OK. > We're reaching the bike-shedding time now, but IMHO having such a > `spawn*` exposed to the user seems fine, it's a pretty simple "raw" > interface with fdes, and there is a convenience `spawn` function that is > nicer for users. =E2=80=98spawn*=E2=80=99 is expressive enough, but a procedure with 6 posit= ional arguments cannot be exposed as-is IMO. One tiny thing that=E2=80=99s missing is a boolean to choose between =E2=80=98posix_spawn=E2=80=99 and =E2=80=98posix_spawnp=E2=80=99. So we need either =E2=80=98spawn=E2=80=99 defined in Scheme as you did, or = directly use =E2=80=98scm_c_bind_keyword_arguments=E2=80=99 right in =E2=80=98scm_spawn_= process=E2=80=99 (info "(guile) Keyword Procedures"), to avoid ending up with two procedures. I=E2=80=99m fine either way. > Do we need to add a documentation page as well? Yes, please. :-) I realize I=E2=80=99m asking a lot of things, so let me = know if you=E2=80=99d like to share the workload somehow. Doc could go in the =E2=80=9CProcesses=E2=80=9D section, or possibly in a n= ew section we=E2=80=99d add right after it, =E2=80=9CSpawning Programs=E2=80=9D. We s= hould probably add a =E2=80=9C@quotation Note=E2=80=9D in the doc of =E2=80=98primitive-fork=E2= =80=99 that briefly explains why people should probably use =E2=80=98spawn=E2=80=99 rather than fork + e= xec. Some cosmetic suggestions follow=E2=80=A6 Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 25 12:03:59 2022 Received: (at 52835) by debbugs.gnu.org; 25 Dec 2022 17:03:59 +0000 Received: from localhost ([127.0.0.1]:50049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9UPm-0006Yx-MM for submit@debbugs.gnu.org; Sun, 25 Dec 2022 12:03:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36506) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9UPl-0006Yl-1d for 52835@debbugs.gnu.org; Sun, 25 Dec 2022 12:03:57 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9UPf-0003TF-KM; Sun, 25 Dec 2022 12:03:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=ROul/PbkArqpB9lYNc/RsUayLE3Yp2TOjbeDw+i8pxc=; b=Zef0hov85hMm2mVc/VKp ONdaw+5BFE4MZ57/Sfw1vijbfnVeGb4xYM2JPfDu+wtOafmdzDsfH9pHGkmdv9K4cOU34KTOqS5g/ QbdoXTdf9mz5qcIVVlOVyggIChARnt+UZG58jsq7hh5Gy5Dwd+n7qjmD7tGG9weL0q1POd/BBiLsC C7AGKvej3TmiSC/OF//QjO0rt7nriTSVoahRB95HvfVNNIPaU4Wmh5EGfBMA9jO7BgJOBdsSX0/VS O2z7wzOpTIGPlBS/Fcal7LE2V3k75glAJkOhWK9BSj7E+GIsJS3KV6VRBiSqVc+Vw6a9Gee5lWPsT +VpmP9sBInP3kQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9UPf-0007Ru-11; Sun, 25 Dec 2022 12:03:51 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Josselin Poiret Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: <87v8m2jb3c.fsf@jpoiret.xyz> <388cbca36850d1837b3c478d9bd9dd5e222215b0.1671815759.git.dev@jpoiret.xyz> Date: Sun, 25 Dec 2022 18:03:48 +0100 In-Reply-To: <388cbca36850d1837b3c478d9bd9dd5e222215b0.1671815759.git.dev@jpoiret.xyz> (Josselin Poiret's message of "Fri, 23 Dec 2022 18:17:05 +0100") Message-ID: <873593xvnv.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Josselin Poiret skribis: > * libguile/posix.c: Include spawn.h from Gnulib. > (do_spawn, scm_spawn_process): New functions. > * module/ice-9/spawn.scm: New file > (spawn): New procedure. > --- > libguile/posix.c | 82 ++++++++++++++++++++++++++++++++++++++++++ > libguile/posix.h | 2 ++ > module/ice-9/spawn.scm | 54 ++++++++++++++++++++++++++++ > 3 files changed, 138 insertions(+) The new module should be added to =E2=80=98am/bootstrap.am=E2=80=99. > +SCM_API SCM scm_spawn_process (SCM prog, SCM args, SCM env, > + SCM in, SCM out, SCM err); Let=E2=80=99s keep it =E2=80=98SCM_INTERNAL=E2=80=99. > +(define* (spawn exec-file > + #:optional (args (list exec-file)) > + #:key (env (environ)) > + (in (current-input-port)) > + (out (current-output-port)) > + (err (current-error-port))) s/exec-file/program/ s/args/arguments/ s/env/environment/ s/in/standard-input/ s/out/standard-output/ s/err/standard-error/ Maybe we could allow these two be either ports or file descriptors? > + "Spawns a new process running the program @var{exec} with arguments > +@var{args}, in the environment specified by the list of environment > +variable strings @var{env}, and with standard input, output and error > +set to the ports specified by @var{in}, @var{out}, @var{err}. Note that > +the last part only works with fd-backed ports." > + (let* ((in (port-with-defaults in "r")) > + (out (port-with-defaults out "w")) > + (err (port-with-defaults err "w")) > + ;; Increment port revealed counts while to prevent ports GC'ing= and > + ;; closing the associated fds while we spawn the process. > + (result (spawn* exec-file > + args > + env > + (port->fdes in) > + (port->fdes out) > + (port->fdes err)))) I believe =E2=80=98spawn*=E2=80=99 is unbound here because it=E2=80=99s def= ined by =E2=80=98scm_init_popen=E2=80=99, which is called within the (ice-9 popen) = module. Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 25 12:04:33 2022 Received: (at 52835) by debbugs.gnu.org; 25 Dec 2022 17:04:33 +0000 Received: from localhost ([127.0.0.1]:50054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9UQL-0006ai-19 for submit@debbugs.gnu.org; Sun, 25 Dec 2022 12:04:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9UQI-0006aR-Or for 52835@debbugs.gnu.org; Sun, 25 Dec 2022 12:04:31 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9UQB-0004OS-6y; Sun, 25 Dec 2022 12:04:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=y6lAfUC46g4rE+6au+F/fhjnqzZ4gS6ucWlZGWyRnPY=; b=gYzq9hJI+UAFIeC3S20D ntuUc5BZh0KT2K8P8OiTP7SIuIBh0+rp9AvzIwLEtFHezFgXorWhDtT+OXGIhlCf+4M4glX3eAcrr KxGAyxG/K+xzs3p3PhuAxVlREVCVgbZsqn67nuHA721Ne5Sp+SgJpRtV6LmIsKjHl2dqPV07NunA8 8kM1s7GPrO/Zp685mEU5ENSQtbLdXaWSsAYyu81zkYaN9yhGOAQ3OXyndVWc8cW6P4LNdKTzeHB7W ASoUAewZffeQRipo4O4DH4GJTIUc+4b0oCWrNYimnn4eWaNWAmF75t+sDiXf/XEXC4oByqzRQy6TI gKeQueJaxlfBIg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9UQ9-0007U9-Vk; Sun, 25 Dec 2022 12:04:22 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Josselin Poiret Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: <388cbca36850d1837b3c478d9bd9dd5e222215b0.1671815759.git.dev@jpoiret.xyz> Date: Sun, 25 Dec 2022 18:04:20 +0100 In-Reply-To: (Josselin Poiret's message of "Fri, 23 Dec 2022 18:17:06 +0100") Message-ID: <87y1qvwh2j.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Josselin Poiret skribis: > * libguile/posix.c (scm_system_star, scm_piped_process): Use do_spawn. > (start_child): Remove function. LGTM, thanks! From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 11:07:06 2023 Received: (at 52835) by debbugs.gnu.org; 7 Jan 2023 16:07:06 +0000 Received: from localhost ([127.0.0.1]:58770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEBir-0006bk-Ok for submit@debbugs.gnu.org; Sat, 07 Jan 2023 11:07:06 -0500 Received: from jpoiret.xyz ([206.189.101.64]:50470) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEBip-0006bc-Nk for 52835@debbugs.gnu.org; Sat, 07 Jan 2023 11:07:04 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 08DEE185306; Sat, 7 Jan 2023 16:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1673107622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eX49vjOe1RWfloU4XjSVv93vKDKHI5ktqY7yq9Mp1Ic=; b=vwWasjS7UcQUzejmew4pIU7fWqRmozJDHm+puE024GNMI+ShZ/jUdM8VydCvSUyvh2LmiE Eh1QCpnwRYnXesjyhfhjsJBb2vHFUCt8U4itaXRZ0Y9agFKsBvr2CEYCbZu8wK0JbgJq+h J1UBSqlagxrmC48K8QxK64+RQp++4xcAjpfPl/W0qR8xaZezMU5kdxGEqDtvD/VPnwREVU hyXCDipF+IbZof4QLejH9vIhbKbvsVwjQsixnzlwT8GP2NIK7b+m//z3kYx9i1JAsHQVNe w1C5L7SEpPQZA+y3l/81bEn5J0HdxiMOuS4zdsKQT2sTnMPlsJhBtOl7Pyk3Lw== From: Josselin Poiret To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly In-Reply-To: <87a63bxvxh.fsf@gnu.org> References: <87iligyyh9.fsf@gnu.org> <87y1qyz909.fsf_-_@gnu.org> <87v8m2jb3c.fsf@jpoiret.xyz> <87a63bxvxh.fsf@gnu.org> Date: Sat, 07 Jan 2023 17:07:01 +0100 Message-ID: <878rie9vmi.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Ludo, Happy new year! Ludovic Court=C3=A8s writes: > =E2=80=98spawn*=E2=80=99 is expressive enough, but a procedure with 6 pos= itional > arguments cannot be exposed as-is IMO. > > One tiny thing that=E2=80=99s missing is a boolean to choose between > =E2=80=98posix_spawn=E2=80=99 and =E2=80=98posix_spawnp=E2=80=99. > > So we need either =E2=80=98spawn=E2=80=99 defined in Scheme as you did, o= r directly use > =E2=80=98scm_c_bind_keyword_arguments=E2=80=99 right in =E2=80=98scm_spaw= n_process=E2=80=99 (info > "(guile) Keyword Procedures"), to avoid ending up with two procedures. > I=E2=80=99m fine either way. I've done the above by using the C functions to bind keyword arguments, and added the #:use-path? keyword argument. One annoying thing though is that since it uses keyword arguments, the first line of the documentation generated by SCM_DEFINE only mentions "spawn program . keyword_args". >> Do we need to add a documentation page as well? > > Yes, please. :-) I realize I=E2=80=99m asking a lot of things, so let m= e know > if you=E2=80=99d like to share the workload somehow. > > Doc could go in the =E2=80=9CProcesses=E2=80=9D section, or possibly in a= new section > we=E2=80=99d add right after it, =E2=80=9CSpawning Programs=E2=80=9D. We= should probably add a > =E2=80=9C@quotation Note=E2=80=9D in the doc of =E2=80=98primitive-fork= =E2=80=99 that briefly explains > why people should probably use =E2=80=98spawn=E2=80=99 rather than fork += exec. I've opted to put it right below primitive-fork, and slightly rewrite the part about pipes in primitive-fork's description to also mention spawn. Let me know if the documentation is not descriptive enough. WDYT? --=20 Josselin Poiret From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 11:07:52 2023 Received: (at 52835) by debbugs.gnu.org; 7 Jan 2023 16:07:52 +0000 Received: from localhost ([127.0.0.1]:58776 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEBjc-0006co-4C for submit@debbugs.gnu.org; Sat, 07 Jan 2023 11:07:52 -0500 Received: from jpoiret.xyz ([206.189.101.64]:50634) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEBja-0006cf-JI for 52835@debbugs.gnu.org; Sat, 07 Jan 2023 11:07:51 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id D69B6185306; Sat, 7 Jan 2023 16:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1673107670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MJBXjWOie8APlGrUlT23ZZYz//PP/iwyxTK97zWoMN0=; b=rwsgpDNHqb5EYq+VUUGGvgyyruODzVmp5xFwLBScpqUAtILGPeSudBvJawIPIjPQ/smow0 OgGzOBFnG07cu01xyUOkZOEGvvKTUrRoirgNt9hRog/UyrWP+sblSgLb52yOa5GTlqzoez CspjobQJ0pdwC4DJCV2DhXMGXbO9rWoKpHJXF77Vg4BfN0u2MVbpM0K+hP1buoYqP1oFYc gcRdkU7UmtFzDmkmmuI+5baYSfBRhQofyvOhIToc1ybD/Vq2bLM9b4APalxu2iFCAF7EA7 byzJ8OfzHvNtur8NWo9sza3IWsya4qOAl2xBvAoJPfpLmdyTAGdQxv0FPdqp8g== From: Josselin Poiret To: Josselin Poiret , =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v8 1/2] Add spawn. Date: Sat, 7 Jan 2023 17:07:46 +0100 Message-Id: <54884b48615fa3291c637eda80e02f94c359485f.1673107558.git.dev@jpoiret.xyz> In-Reply-To: <878rie9vmi.fsf@jpoiret.xyz> References: <878rie9vmi.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * libguile/posix.c: Include spawn.h from Gnulib. (do_spawn, scm_spawn_process): New functions. --- doc/ref/posix.texi | 34 ++++++++-- libguile/posix.c | 162 ++++++++++++++++++++++++++++++++++++++++++++- libguile/posix.h | 1 + 3 files changed, 192 insertions(+), 5 deletions(-) diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index bde0f150c..36e1f5040 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -2045,15 +2045,41 @@ safe to call after a multithreaded fork, which is a very limited set. Guile issues a warning if it detects a fork from a multi-threaded program. -If you are going to @code{exec} soon after forking, the procedures in -@code{(ice-9 popen)} may be useful to you, as they fork and exec within -an async-signal-safe function carefully written to ensure robust program -behavior, even in the presence of threads. @xref{Pipes}, for more. +@quotation Note +If you are only looking to fork+exec with some pipes set up, using pipes +or the more primitive @code{spawn} will be more robust (e.g. in the +presence of threads), and is more portable. @xref{Pipes} for more. +@end quotation This procedure has been renamed from @code{fork} to avoid a naming conflict with the scsh fork. @end deffn +@deffn {Scheme Procedure} spawn program [#:args=(list program)] @ + [#:env=(environ)] [#:in=(fileno (current-input-port))] @ + [#:out=(fileno (current-output-port))] @ + [#:err=(fileno (current-error-port))] @ + [#:use-path?=#t] + +Spawns a new child process executing @var{program} with argument list +@var{args} (which must include the name of the executable as a first +element), with its environment variables set to @var{env} and standard +input/output/error file descriptors to @var{in}, @var{out}, @var{err}, +after closing all other file descriptors. When @var{use-path?} is +false, @var{program} should be a path to an executable file, but when +@var{use-path?} is true, the environment variable @code{PATH} is +searched to find the corresponding executable. + +Failure to exec in the child may be caught early and reported as an +exception, or the child may also exit with return code 127, depending on +how spawn is implemented for the specific system. You therefore must be +able to handle both cases. + +The return value is the pid of the spawned child process. + +This procedure is portable and should be thread-safe. +@end deffn + @deffn {Scheme Procedure} nice incr @deffnx {C Function} scm_nice (incr) @cindex process priority diff --git a/libguile/posix.c b/libguile/posix.c index b5352c2c4..f79875075 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef HAVE_SCHED_H # include @@ -63,6 +64,7 @@ #include "fports.h" #include "gettext.h" #include "gsubr.h" +#include "keywords.h" #include "list.h" #include "modules.h" #include "numbers.h" @@ -1426,6 +1428,158 @@ start_child (const char *exec_file, char **exec_argv, } #endif +static pid_t +do_spawn (char *exec_file, char **exec_argv, char **exec_env, + int in, int out, int err, int spawnp) +{ + pid_t pid = -1; + + posix_spawn_file_actions_t actions; + posix_spawnattr_t *attrp = NULL; + + int max_fd = 1024; + +#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) + { + struct rlimit lim = { 0, 0 }; + if (getrlimit (RLIMIT_NOFILE, &lim) == 0) + max_fd = lim.rlim_cur; + } +#endif + + posix_spawn_file_actions_init (&actions); + + int free_fd_slots = 0; + int fd_slot[3]; + + for (int fdnum = 3;free_fd_slots < 3 && fdnum < max_fd;fdnum++) + { + if (fdnum != in && fdnum != out && fdnum != err) + { + fd_slot[free_fd_slots] = fdnum; + free_fd_slots++; + } + } + + /* Move the fds out of the way, so that duplicate fds or fds equal + to 0, 1, 2 don't trample each other */ + + posix_spawn_file_actions_adddup2 (&actions, in, fd_slot[0]); + posix_spawn_file_actions_adddup2 (&actions, out, fd_slot[1]); + posix_spawn_file_actions_adddup2 (&actions, err, fd_slot[2]); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[0], 0); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[1], 1); + posix_spawn_file_actions_adddup2 (&actions, fd_slot[2], 2); + + while (--max_fd > 2) + posix_spawn_file_actions_addclose (&actions, max_fd); + + int res = -1; + if (spawnp) + res = posix_spawnp (&pid, exec_file, &actions, attrp, + exec_argv, exec_env); + else + res = posix_spawn (&pid, exec_file, &actions, attrp, + exec_argv, exec_env); + if (res != 0) + return -1; + + return pid; +} + +SCM k_args, k_env, k_in, k_out, k_err, k_use_path; + +SCM_DEFINE (scm_spawn_process, "spawn", 1, 0, 1, + (SCM program, SCM keyword_args), + "Spawns a new child process executing @var{program} with no arguments.\n\n" + "If the boolean keyword argument @code{#:use-path?} is provided, it\n" + "selects whether the @code{PATH} environment variable should be\n" + "inspected to find @var{program}. It is true by default.\n\n" + "If the keyword arguments @code{#:args}, @code{#:env}, are provided,\n" + "they respectively modify the arguments or the environment of the\n" + "spawning program.\n\n" + "If the keyword arguments @code{#:in}, @code{#:out} or @code{#:err}\n" + "are provided, they respectively modify the default input, output\n" + "and error file descriptor of the spawning program to these values.") +#define FUNC_NAME s_scm_spawn_process +{ + SCM args, env, in_scm, out_scm, err_scm, use_path; + args = SCM_UNDEFINED; + env = SCM_UNDEFINED; + in_scm = SCM_UNDEFINED; + out_scm = SCM_UNDEFINED; + err_scm = SCM_UNDEFINED; + use_path = SCM_BOOL_T; + + scm_c_bind_keyword_arguments (FUNC_NAME, keyword_args, 0, + k_args, &args, + k_env, &env, + k_in, &in_scm, + k_out, &out_scm, + k_err, &err_scm, + k_use_path, &use_path, + SCM_UNDEFINED); + + int pid = -1; + char *exec_file; + char **exec_argv; + char **exec_env; + int in, out, err; + + exec_file = scm_to_locale_string (program); + + if (SCM_UNBNDP (args)) + { + /* We use scm_gc_malloc here because that's the same as what + scm_i_allocate_string_pointers would do. */ + exec_argv = scm_gc_malloc (2 * sizeof (char *), + "string pointers"); + exec_argv[0] = exec_file; + exec_argv[1] = NULL; + } + else + { + exec_argv = scm_i_allocate_string_pointers (args); + if (exec_argv[0] == NULL) + { + free (exec_file); + scm_misc_error (FUNC_NAME, "Argument list must not be empty.", + SCM_EOL); + } + } + + if (SCM_UNBNDP (env)) + exec_env = environ; + else + exec_env = scm_i_allocate_string_pointers (env); + + if (SCM_UNBNDP (in_scm)) + in = SCM_FPORT_FDES (scm_current_input_port ()); + else + in = scm_to_int (in_scm); + + if (SCM_UNBNDP (out_scm)) + out = SCM_FPORT_FDES (scm_current_output_port ()); + else + out = scm_to_int (out_scm); + + if (SCM_UNBNDP (err_scm)) + err = SCM_FPORT_FDES (scm_current_error_port ()); + else + err = scm_to_int (err_scm); + + pid = do_spawn (exec_file, exec_argv, exec_env, + in, out, err, scm_to_bool (use_path)); + + free (exec_file); + + if (pid == -1) + SCM_SYSERROR; + + return scm_from_int (pid); +} +#undef FUNC_NAME + #ifdef HAVE_START_CHILD static SCM scm_piped_process (SCM prog, SCM args, SCM from, SCM to) @@ -2547,5 +2701,11 @@ scm_init_posix () "scm_init_popen", (scm_t_extension_init_func) scm_init_popen, NULL); -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ + k_args = scm_from_utf8_keyword ("args"); + k_env = scm_from_utf8_keyword ("env"); + k_in = scm_from_utf8_keyword ("in"); + k_out = scm_from_utf8_keyword ("out"); + k_err = scm_from_utf8_keyword ("err"); + k_use_path = scm_from_utf8_keyword ("use-path?"); } diff --git a/libguile/posix.h b/libguile/posix.h index 6504eaea8..5eeafd4cb 100644 --- a/libguile/posix.h +++ b/libguile/posix.h @@ -69,6 +69,7 @@ SCM_API SCM scm_tmpnam (void); SCM_API SCM scm_tmpfile (void); SCM_API SCM scm_open_pipe (SCM pipestr, SCM modes); SCM_API SCM scm_close_pipe (SCM port); +SCM_API SCM scm_spawn_process (SCM prog, SCM keyword_args); SCM_API SCM scm_system_star (SCM cmds); SCM_API SCM scm_utime (SCM object, SCM actime, SCM modtime, SCM actimens, SCM modtimens, SCM flags); base-commit: 4711d45176e9b75cef43699ed514669276af62fe -- 2.38.1 From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 11:07:55 2023 Received: (at 52835) by debbugs.gnu.org; 7 Jan 2023 16:07:55 +0000 Received: from localhost ([127.0.0.1]:58778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEBje-0006d2-Su for submit@debbugs.gnu.org; Sat, 07 Jan 2023 11:07:55 -0500 Received: from jpoiret.xyz ([206.189.101.64]:50722) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEBjb-0006cm-Ql for 52835@debbugs.gnu.org; Sat, 07 Jan 2023 11:07:52 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id A11FC185318; Sat, 7 Jan 2023 16:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1673107671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gE7CwTy11pqrqawSZQk2AWa2T5DSIirG2e8sxd+l9nc=; b=ZGrK6dgG719jaRibfztDsYgJhnOJD/NU070khDKJUXT3lXNrsovZEv0HT0ryW4IM73S7s8 06D1Xv/DrciDSpqC64bh4UowjIa75yQfQmKd6/yp0MbYsv8Wq6czZ0g/hjNA42IjJVwOIt iJjwoGNgKcB760Z2DWhEgLZl2olcylVZwnMIVFgS1w4DdleiLiswK7DizWinpMoTwRy/ee W0591vcT/8mIxEz+KWBy1e9OLaIxrx3y17ZTBHX8WFwxjFKcK61YusDvHk6BFjGIUfrP74 dDzpqsqRr4GENAaXjOI7FAzeSD8qoMzxLz9OsAw1+FargApJuCPVOPWNUKILLg== From: Josselin Poiret To: Josselin Poiret , =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v8 2/2] Make system* and piped-process internally use spawn. Date: Sat, 7 Jan 2023 17:07:47 +0100 Message-Id: In-Reply-To: <54884b48615fa3291c637eda80e02f94c359485f.1673107558.git.dev@jpoiret.xyz> References: <54884b48615fa3291c637eda80e02f94c359485f.1673107558.git.dev@jpoiret.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: --- X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * libguile/posix.c (scm_system_star, scm_piped_process): Use do_spawn. (start_child): Remove function. Co-authored-by: Ludovic Courtès --- libguile/posix.c | 231 ++++++++++++++++------------------------------- 1 file changed, 77 insertions(+), 154 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index f79875075..2c6c3c84a 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -78,6 +78,7 @@ #include "threads.h" #include "values.h" #include "vectors.h" +#include "verify.h" #include "version.h" #if (SCM_ENABLE_DEPRECATED == 1) @@ -96,6 +97,13 @@ # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif +#ifndef W_EXITCODE +/* Macro for constructing a status value. Found in glibc. */ +# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) +#endif +verify (WEXITSTATUS (W_EXITCODE (127, 0)) == 127); + + #include #ifdef HAVE_GRP_H @@ -1309,125 +1317,6 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #undef FUNC_NAME #endif /* HAVE_FORK */ -#ifdef HAVE_FORK -/* 'renumber_file_descriptor' is a helper function for 'start_child' - below, and is specialized for that particular environment where it - doesn't make sense to report errors via exceptions. It uses dup(2) - to duplicate the file descriptor FD, closes the original FD, and - returns the new descriptor. If dup(2) fails, print an error message - to ERR and abort. */ -static int -renumber_file_descriptor (int fd, int err) -{ - int new_fd; - - do - new_fd = dup (fd); - while (new_fd == -1 && errno == EINTR); - - if (new_fd == -1) - { - /* At this point we are in the child process before exec. We - cannot safely raise an exception in this environment. */ - const char *msg = strerror (errno); - fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg); - _exit (127); /* Use exit status 127, as with other exec errors. */ - } - - close (fd); - return new_fd; -} -#endif /* HAVE_FORK */ - -#ifdef HAVE_FORK -#define HAVE_START_CHILD 1 -/* Since Guile uses threads, we have to be very careful to avoid calling - functions that are not async-signal-safe in the child. That's why - this function is implemented in C. */ -static pid_t -start_child (const char *exec_file, char **exec_argv, - int reading, int c2p[2], int writing, int p2c[2], - int in, int out, int err) -{ - int pid; - int max_fd = 1024; - -#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_NOFILE) - { - struct rlimit lim = { 0, 0 }; - if (getrlimit (RLIMIT_NOFILE, &lim) == 0) - max_fd = lim.rlim_cur; - } -#endif - - pid = fork (); - - if (pid != 0) - /* The parent, with either and error (pid == -1), or the PID of the - child. Return directly in either case. */ - return pid; - - /* The child. */ - if (reading) - close (c2p[0]); - if (writing) - close (p2c[1]); - - /* Close all file descriptors in ports inherited from the parent - except for in, out, and err. Heavy-handed, but robust. */ - while (max_fd--) - if (max_fd != in && max_fd != out && max_fd != err) - close (max_fd); - - /* Ignore errors on these open() calls. */ - if (in == -1) - in = open ("/dev/null", O_RDONLY); - if (out == -1) - out = open ("/dev/null", O_WRONLY); - if (err == -1) - err = open ("/dev/null", O_WRONLY); - - if (in > 0) - { - if (out == 0) - out = renumber_file_descriptor (out, err); - if (err == 0) - err = renumber_file_descriptor (err, err); - do dup2 (in, 0); while (errno == EINTR); - close (in); - } - if (out > 1) - { - if (err == 1) - err = renumber_file_descriptor (err, err); - do dup2 (out, 1); while (errno == EINTR); - if (out > 2) - close (out); - } - if (err > 2) - { - do dup2 (err, 2); while (errno == EINTR); - close (err); - } - - execvp (exec_file, exec_argv); - - /* The exec failed! There is nothing sensible to do. */ - { - const char *msg = strerror (errno); - fprintf (fdopen (2, "a"), "In execvp of %s: %s\n", - exec_file, msg); - } - - /* Use exit status 127, like shells in this case, as per POSIX - . */ - _exit (127); - - /* Not reached. */ - return -1; -} -#endif - static pid_t do_spawn (char *exec_file, char **exec_argv, char **exec_env, int in, int out, int err, int spawnp) @@ -1580,18 +1469,18 @@ SCM_DEFINE (scm_spawn_process, "spawn", 1, 0, 1, } #undef FUNC_NAME -#ifdef HAVE_START_CHILD -static SCM -scm_piped_process (SCM prog, SCM args, SCM from, SCM to) +#ifdef HAVE_FORK +static int +piped_process (pid_t *pid, SCM prog, SCM args, SCM from, SCM to) #define FUNC_NAME "piped-process" { int reading, writing; int c2p[2]; /* Child to parent. */ int p2c[2]; /* Parent to child. */ int in = -1, out = -1, err = -1; - int pid; char *exec_file; char **exec_argv; + char **exec_env = environ; exec_file = scm_to_locale_string (prog); exec_argv = scm_i_allocate_string_pointers (scm_cons (prog, args)); @@ -1624,32 +1513,57 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to) in = SCM_FPORT_FDES (port); } - pid = start_child (exec_file, exec_argv, reading, c2p, writing, p2c, - in, out, err); - - if (pid == -1) - { - int errno_save = errno; - free (exec_file); - if (reading) - { - close (c2p[0]); - close (c2p[1]); - } - if (writing) - { - close (p2c[0]); - close (p2c[1]); - } - errno = errno_save; - SCM_SYSERROR; - } + *pid = do_spawn (exec_file, exec_argv, exec_env, in, out, err, 1); + int errno_save = (*pid < 0) ? errno : 0; if (reading) close (c2p[1]); if (writing) close (p2c[0]); + if (*pid == -1) + switch (errno_save) + { + /* Errors that seemingly come from fork. */ + case EAGAIN: + case ENOMEM: + case ENOSYS: + errno = err; + free (exec_file); + SCM_SYSERROR; + break; + + default: /* ENOENT, etc. */ + /* Create a dummy process that exits with value 127. */ + dprintf (err, "In execvp of %s: %s\n", exec_file, + strerror (errno_save)); + } + + free (exec_file); + + return errno_save; +} +#undef FUNC_NAME + +static SCM +scm_piped_process (SCM prog, SCM args, SCM from, SCM to) +#define FUNC_NAME "piped-process" +{ + pid_t pid; + + (void) piped_process (&pid, prog, args, from, to); + if (pid == -1) + { + /* Create a dummy process that exits with value 127 to mimic the + previous fork + exec implementation. TODO: This is a + compatibility shim to remove in the next stable series. */ + pid = fork (); + if (pid == -1) + SCM_SYSERROR; + if (pid == 0) + _exit (127); + } + return scm_from_int (pid); } #undef FUNC_NAME @@ -1695,8 +1609,9 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, "Example: (system* \"echo\" \"foo\" \"bar\")") #define FUNC_NAME s_scm_system_star { - SCM prog, pid; - int status, wait_result; + SCM prog; + pid_t pid; + int err, status, wait_result; if (scm_is_null (args)) SCM_WRONG_NUM_ARGS (); @@ -1714,17 +1629,27 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, SCM_UNDEFINED); #endif - pid = scm_piped_process (prog, args, SCM_UNDEFINED, SCM_UNDEFINED); - SCM_SYSCALL (wait_result = waitpid (scm_to_int (pid), &status, 0)); - if (wait_result == -1) - SCM_SYSERROR; + err = piped_process (&pid, prog, args, + SCM_UNDEFINED, SCM_UNDEFINED); + if (err != 0) + /* ERR might be ENOENT or similar. For backward compatibility with + the previous implementation based on fork + exec, pretend the + child process exited with code 127. TODO: Remove this + compatibility shim in the next stable series. */ + status = W_EXITCODE (127, 0); + else + { + SCM_SYSCALL (wait_result = waitpid (pid, &status, 0)); + if (wait_result == -1) + SCM_SYSERROR; + } scm_dynwind_end (); return scm_from_int (status); } #undef FUNC_NAME -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ #ifdef HAVE_UNAME SCM_DEFINE (scm_uname, "uname", 0, 0, 0, @@ -2570,13 +2495,13 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0, #endif /* HAVE_GETHOSTNAME */ -#ifdef HAVE_START_CHILD +#ifdef HAVE_FORK static void scm_init_popen (void) { scm_c_define_gsubr ("piped-process", 2, 2, 0, scm_piped_process); } -#endif /* HAVE_START_CHILD */ +#endif /* HAVE_FORK */ void scm_init_posix () @@ -2694,8 +2619,6 @@ scm_init_posix () #ifdef HAVE_FORK scm_add_feature ("fork"); -#endif /* HAVE_FORK */ -#ifdef HAVE_START_CHILD scm_add_feature ("popen"); scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION, "scm_init_popen", -- 2.38.1 From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 12 17:02:29 2023 Received: (at 52835) by debbugs.gnu.org; 12 Jan 2023 22:02:29 +0000 Received: from localhost ([127.0.0.1]:48732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pG5eW-0003v4-VM for submit@debbugs.gnu.org; Thu, 12 Jan 2023 17:02:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pG5eU-0003ur-HM for 52835@debbugs.gnu.org; Thu, 12 Jan 2023 17:02:27 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pG5eO-0002Xk-Ts; Thu, 12 Jan 2023 17:02:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=Gc0W+otNtFbqzVAMSoJvmT3jC9asTNs1E7ZVCB64CWM=; b=JupFu9K5HGynjS1ZooAR mPE1HPjQbkWukKkb8UALwqSIFnRK2Xuy/HP5taprSnq2ScCXJkV7IONCHFVoc7AQZegUkmiTPelKJ su+9qu7l0575OmzgAT73WjkBhywjtN3xx0PmXbCGl9JVpyToGF8fW1khzfrFBNl57ehzopH4XpVFE FPwhMavyFHXZj5Rz5Spj6Us6Tf1bCuDyyEp07RQBKompT8/7JxFD5ezWyDYofRmp2ltr8MZ8ravNo KUhTh0O54bOldJptCOXa5Ya5cc3j51dN10qnKQEcH2Kg9yl4sJQEHMKmUOOISA0KOz91R0X4I78sD La5YV8pKZgliRA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pG5eM-0005Fq-Fs; Thu, 12 Jan 2023 17:02:20 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Josselin Poiret Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: <87iligyyh9.fsf@gnu.org> <87y1qyz909.fsf_-_@gnu.org> <87v8m2jb3c.fsf@jpoiret.xyz> <87a63bxvxh.fsf@gnu.org> <878rie9vmi.fsf@jpoiret.xyz> Date: Thu, 12 Jan 2023 23:02:15 +0100 In-Reply-To: <878rie9vmi.fsf@jpoiret.xyz> (Josselin Poiret's message of "Sat, 07 Jan 2023 17:07:01 +0100") Message-ID: <871qnzh0ns.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 52835 Cc: 52835@debbugs.gnu.org, Timothy Sample X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Josselin, and a happy new year full of good hacks! :-) Josselin Poiret skribis: > I've done the above by using the C functions to bind keyword arguments, > and added the #:use-path? keyword argument. One annoying thing though > is that since it uses keyword arguments, the first line of the > documentation generated by SCM_DEFINE only mentions "spawn program > . keyword_args". That=E2=80=99s OK. > I've opted to put it right below primitive-fork, and slightly rewrite > the part about pipes in primitive-fork's description to also mention > spawn. Let me know if the documentation is not descriptive enough. It looks good to me. A few suggestions of mine got lost, so I pushed a new =E2=80=98wip-posix-sp= awn=E2=80=99 with additional commits taking those into account and adding tests. The changes in this v8.1 are: - make 'arguments' positional rather than keyword - rename keyword arguments to avoid abbreviations - add example in the manual - mark 'scm_spawn_process' as SCM_INTERNAL - add tests Because this is now a core binding and no longer in (ice-9 spawn), I hope =E2=80=98spawn=E2=80=99 is not clashing with someone else=E2=80=99s li= brary, though the worst that could happen is a run-time warning =E2=80=9Cmodule X overrides c= ore binding 'spawn'=E2=80=9D. I=E2=80=99m very pleased with the branch and could finally merge if you agr= ee! (I=E2=80=99ll put myself as co-author and take the blame for half of the bu= gs. :-)) Ah yes, one thing that came to mind: we could change #:input #f to mean =E2=80=9Cclose file descriptor 0=E2=80=9D, and so on. Let=E2=80=99s first = merge this, though. Thoughts? Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 13 03:27:28 2023 Received: (at 52835) by debbugs.gnu.org; 13 Jan 2023 08:27:28 +0000 Received: from localhost ([127.0.0.1]:49466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGFPK-0001LE-Ql for submit@debbugs.gnu.org; Fri, 13 Jan 2023 03:27:28 -0500 Received: from dandenongnorth.hosting-cloud.net ([103.146.113.52]:47457) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pG8bX-0000mb-HH for 52835@debbugs.gnu.org; Thu, 12 Jan 2023 20:11:39 -0500 X-Mailborder-Info: host=console.hosting-cloud.net, gmt_time=1673572291, scan_time=6.44s X-Mailborder-Spam-Score: -0.1 X-Mailborder-Spam-Report: ALL_TRUSTED, BAYES_00, MC_QUOATION, URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS, SPF_FAIL, DKIM_SIGNED, MB_DMARC_FAIL, DKIM_INVALID, Received: from cp61.hosting-cloud.net (unknown [103.119.110.239]) by smtp.hosting-cloud.net (Postfix) with ESMTPSA id 66F8980221 for <52835@debbugs.gnu.org>; Fri, 13 Jan 2023 12:11:18 +1100 (AEDT) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.hosting-cloud.net 66F8980221 Authentication-Results: console.hosting-cloud.net; dmarc=fail (p=quarantine dis=none) header.from=tailcall.au Authentication-Results: console.hosting-cloud.net; spf=fail smtp.mailfrom=whatson@tailcall.au DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.hosting-cloud.net 66F8980221 Authentication-Results: smtp.hosting-cloud.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=tailcall.au header.i=@tailcall.au header.b="luYmesCw"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tailcall.au ; s=x; h=Content-Transfer-Encoding:Content-Type:Message-ID:Subject:To:From: Date:MIME-Version:Sender:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Md8Qzrn6mtpnINrvKt1LmbSKjE2zM0WcL6u/T2cmKlg=; b=luYmesCwgRdsl+uPY1dw2ojZkY HI0j27jOhW0xGvUyeh158mwpN0hiNAT7OwCOzoHwFNTrOvAm7z6IpEw9YCXKk3bs3Hi5slBjTg7RB 0JiYlw4rd3veixPSodFj8pMuIGXvfHHcmw2F7GQ+M0EvXv/9FKgXyr1KDYGIelWvPIi+pbY6PfqGY SYkGFjyMzP02iCms4eMKceSQwT+7VfKRGe0P1RYLiwvcY+BUWb9/wefxnqBPdrEEXfJB0MfVVcKDq meoVYk29OXvQgtgfVIDWS3vse3a7R6YelF/o/FBTo/ovX5TRH+/p/6i4VxUoIiioarpQNuG534+th XaF6fWQg==; Received: from localhost ([127.0.0.1] helo=cp61.hosting-cloud.net) by cp61.hosting-cloud.net with esmtpa (Exim 4.96) (envelope-from ) id 1pG8bG-0057X2-1M for 52835@debbugs.gnu.org; Fri, 13 Jan 2023 12:11:18 +1100 MIME-Version: 1.0 Date: Fri, 13 Jan 2023 11:11:18 +1000 From: Andrew Whatson To: 52835@debbugs.gnu.org Subject: Re: [PATCH 0/2] Fix spawning a child not setting standard fds properly Message-ID: <83e7661b7b89afbe406184b3c12a0310@tailcall.au> X-Sender: whatson@tailcall.au Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-AuthUser: whatson@tailcall.au X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 52835 X-Mailman-Approved-At: Fri, 13 Jan 2023 03:27:24 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello Josselin & Ludo, Thanks for your work on this, posix_spawn is a nice improvement! My comments on the changes in the wip-posix-spawn branch follow. In doc/ref/posix.texi: > @quotation Note > If you are only looking to fork+exec with some pipes set up, using > pipes > or the more @code{spawn} procedure described below will be more robust > (in particular in multi-threaded contexts), more portable, and usually > more efficient. > @end quotation Should be "... the more primitive @code{spawn} procedure". > @deffn {Scheme Procedure} spawn @var{program} @var{arguments} @ > [#:environment=(environ)] @ > [#:input=(current-input-port)] @ > [#:output=(current-output-port)] @ > [#:error=(current-error-port)] @ > [#:search-path?=#t] > Spawn a new child process executing @var{program} with the > given @var{arguments}, a list of one or more strings, and > return its PID. Raise a @code{system-error} exception if > @var{program} could not be found or could not be executed. The description of arguments as "a list of one or more strings" is surprising, I think some users might expect to be able to pass zero arguments, but we don't explain what the single argument should be. An earlier version of the docs for this function clarified this with "(which must include the name of the executable as a first element)". The manual for exec(3) says "the first argument, by convention, should point to the filename associated with the file being executed." Maybe we could clarify in a second paragraph: "By convention, the first element of @var{arguments} should be the name of the program being executed. If calling a C program, for example, this will be passed as the value for @code{argv[0]}." In libguile/posix.c, piped_process, around line 1565: > if (*pid == -1) > switch (errno_save) > { > /* Errors that seemingly come from fork. */ > case EAGAIN: > case ENOMEM: > case ENOSYS: > errno = err; > free (exec_file); > SCM_SYSERROR; > break; > > default: /* ENOENT, etc. */ > /* Create a dummy process that exits with value 127. */ > dprintf (err, "In execvp of %s: %s\n", exec_file, > strerror (errno_save)); > } The "dummy process" comment here is misleading, this function simply returns the error code. Its callers 'scm_piped_process' and 'scm_system_star' are responsible for simulating exit code 127, and are already well commented. Probably just remove this redundant comment. Otherwise, looks good to me :) Thanks again! Cheers, Andrew From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 13 10:20:51 2023 Received: (at 52835-done) by debbugs.gnu.org; 13 Jan 2023 15:20:51 +0000 Received: from localhost ([127.0.0.1]:52151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGLrP-0005Jh-19 for submit@debbugs.gnu.org; Fri, 13 Jan 2023 10:20:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGLrN-0005JN-GY for 52835-done@debbugs.gnu.org; Fri, 13 Jan 2023 10:20:49 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGLrD-0000FI-77; Fri, 13 Jan 2023 10:20:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=iSD93xd/4K834COndMIgMoK1sxX6o5WFKatbJaxgFxg=; b=Zf7CGQtkGjz3mqdhf2BQ ptgaH3sWovDR3XCJt+GKyIYc+y/Lt+qWUR+M+QQXisFsNhGe5C2nhyMO/pebEGp5DElisrm4UFCi4 U9/+9VJzlCl5Px3GD32ilRa+m2LHEXh6NJywu5gyPx+uWxrosV425rC3hZ6Z3pBQV1NvNvM+KQ8QU 6UbZ+njiIr4FBeQttaP0IetXFcCC7EiGmuw2zECsJdq4hqsCyt+vkL7SIFwJh9jZXDlg6JJ1sbK0a 1nqegg9b2T0YsbRKr8vnZfxtMoOuLEMtJEqYROJKyZ10HNMIEnKdHdi7qnTqPEwrPDf+VmgZn0/vJ 7/LuM23MV6Vo1w==; Received: from [193.50.110.246] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGLrB-0003i1-I6; Fri, 13 Jan 2023 10:20:39 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Andrew Whatson Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly References: <83e7661b7b89afbe406184b3c12a0310@tailcall.au> Date: Fri, 13 Jan 2023 16:20:28 +0100 In-Reply-To: <83e7661b7b89afbe406184b3c12a0310@tailcall.au> (Andrew Whatson's message of "Fri, 13 Jan 2023 11:11:18 +1000") Message-ID: <87k01qbgw3.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 52835-done Cc: 52835-done@debbugs.gnu.org, Josselin Poiret X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Andrew & Josselin, Andrew Whatson skribis: > Thanks for your work on this, posix_spawn is a nice improvement! > > My comments on the changes in the wip-posix-spawn branch follow. As discussed on IRC, I took your comments into account. I also added a =E2=80=98system*=E2=80=99 test based on what Josselin provided at the begin= ning of this bug report (let=E2=80=99s not forget we were initially fixing an actual bug= :-)) and updated =E2=80=98NEWS=E2=80=99: 527c257d6 Make 'system*' and 'piped-process' internally use 'spawn'. 551929e4f Add 'spawn'. edfca3b7e Update gnulib to 0.1.5414-8204d and add posix_spawn, posix_spaw= np. Let me know if you notice anything fishy! Thanks a lot, Josselin, for your hard work and for your patience. Ludo=E2=80=99. From unknown Wed Jun 18 23:00:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 11 Feb 2023 12:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator