public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4630] Handle jobserver file descriptors in btest. Date: Fri, 22 Oct 2021 19:12:46 +0000 (GMT) [thread overview] Message-ID: <20211022191246.2EBB93858416@sourceware.org> (raw) https://gcc.gnu.org/g:690180eb4b35df3f4b5def690878ecaeb5492e41 commit r12-4630-g690180eb4b35df3f4b5def690878ecaeb5492e41 Author: Martin Liska <mliska@suse.cz> Date: Fri Oct 22 10:12:56 2021 +0200 Handle jobserver file descriptors in btest. PR testsuite/102742 libbacktrace/ChangeLog: * btest.c (MIN_DESCRIPTOR): New. (MAX_DESCRIPTOR): Likewise. (check_available_files): Likewise. (check_open_files): Check only file descriptors that were not available at the entry. (main): Call check_available_files. Diff: --- libbacktrace/btest.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c index 9f9c03babf3..7ef6d320497 100644 --- a/libbacktrace/btest.c +++ b/libbacktrace/btest.c @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/stat.h> #include "filenames.h" @@ -458,16 +459,29 @@ test5 (void) return failures; } +#define MIN_DESCRIPTOR 3 +#define MAX_DESCRIPTOR 10 + +static int fstat_status[MAX_DESCRIPTOR]; + +/* Check files that are available. */ + +static void +check_available_files (void) +{ + struct stat s; + for (unsigned i = MIN_DESCRIPTOR; i < MAX_DESCRIPTOR; i++) + fstat_status[i] = fstat (i, &s); +} + /* Check that are no files left open. */ static void check_open_files (void) { - int i; - - for (i = 3; i < 10; i++) + for (unsigned i = MIN_DESCRIPTOR; i < MAX_DESCRIPTOR; i++) { - if (close (i) == 0) + if (fstat_status[i] != 0 && close (i) == 0) { fprintf (stderr, "ERROR: descriptor %d still open after tests complete\n", @@ -482,6 +496,8 @@ check_open_files (void) int main (int argc ATTRIBUTE_UNUSED, char **argv) { + check_available_files (); + state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS, error_callback_create, NULL);
reply other threads:[~2021-10-22 19:12 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211022191246.2EBB93858416@sourceware.org \ --to=marxin@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).