public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR102742-fix-btest-and-jobserver)] Handle jobserver file descriptors in btest.
@ 2021-10-21  7:46 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-10-21  7:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a5a48835d66843d0f1ab64917681804e9ab49f4c

commit a5a48835d66843d0f1ab64917681804e9ab49f4c
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Oct 21 09:45:33 2021 +0200

    Handle jobserver file descriptors in btest.
    
            PR testsuite/102742
    
    libbacktrace/ChangeLog:
    
            * btest.c (check_open_files): Ignore file descriptors provided
            by jobserver.

Diff:
---
 libbacktrace/btest.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c
index 9f9c03babf3..a1ea93728be 100644
--- a/libbacktrace/btest.c
+++ b/libbacktrace/btest.c
@@ -464,9 +464,25 @@ static void
 check_open_files (void)
 {
   int i;
+  int rfd = -1;
+  int wfd = -1;
+
+#define JS_NEEDLE "--jobserver-auth="
+
+  /* Ignore file descriptors provided by jobserver.  */
+  const char *makeflags = getenv ("MAKEFLAGS");
+  if (makeflags != NULL)
+    {
+      const char *n = strstr (makeflags, JS_NEEDLE);
+      if (n != NULL)
+	sscanf (n + strlen (JS_NEEDLE), "%d,%d", &rfd, &wfd);
+    }
 
   for (i = 3; i < 10; i++)
     {
+      if (i == rfd || i == wfd)
+	continue;
+
       if (close (i) == 0)
 	{
 	  fprintf (stderr,


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-21  7:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21  7:46 [gcc(refs/users/marxin/heads/PR102742-fix-btest-and-jobserver)] Handle jobserver file descriptors in btest Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).