Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@cygnus.com>
To: Michael Snyder <msnyder@cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: [PATCH RFA] Retry open of /proc/PID/ctl in procfs.c
Date: Fri, 13 Apr 2001 01:14:00 -0000	[thread overview]
Message-ID: <1010413081401.ZM18512@ocotillo.lan> (raw)

I request approval for committing the patch below.  The comments in the
patch explain why this patch is needed.  (It definitely cures some
intermittent problems that I'm seeing on AIX5.)

Tested on i586-sco-sysv5uw7.1.1 and i386-pc-solaris2.8.  No regressions.

	* procfs.c (procfs_init_inferior): Add code for retrying the
	open of the /proc control file for the newly created process.

Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.26
diff -u -p -r1.26 procfs.c
--- procfs.c	2001/03/27 02:01:11	1.26
+++ procfs.c	2001/04/13 07:57:26
@@ -4773,6 +4773,7 @@ procfs_init_inferior (int pid)
   procinfo *pi;
   gdb_sigset_t signals;
   int fail;
+  int retry_count;
 
   /* This routine called on the parent side (GDB side)
      after GDB forks the inferior.  */
@@ -4782,8 +4783,25 @@ procfs_init_inferior (int pid)
   if ((pi = create_procinfo (pid, 0)) == NULL)
     perror ("procfs: out of memory in 'init_inferior'");
 
-  if (!open_procinfo_files (pi, FD_CTL))
-    proc_error (pi, "init_inferior, open_proc_files", __LINE__);
+  /* Open the /proc control (ctl) file, but be prepared to retry
+     this open in the event that it hasn't been created yet.  */
+  retry_count = 3;
+  while (!open_procinfo_files (pi, FD_CTL))
+    {
+      if (retry_count == 0)
+	{
+	  /* Retry count exceeded; print error and return to top level.  */
+	  proc_error (pi, "init_inferior, open_proc_files", __LINE__);
+	}
+      else
+	{
+	  /* In some /proc implementations, GDB tries to open /proc/PID/ctl
+	     before the kernel has created it.  Sleep for a bit to give
+	     the kernel a chance to catch up.  */
+	  sleep (1);
+	  retry_count--;
+	}
+    }
 
   /*
     xmalloc			// done


             reply	other threads:[~2001-04-13  1:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-13  1:14 Kevin Buettner [this message]
     [not found] ` <3AD77C7C.C9D4037C@cygnus.com>
2001-04-13 16:12   ` Kevin Buettner

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=1010413081401.ZM18512@ocotillo.lan \
    --to=kevinb@cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=msnyder@cygnus.com \
    /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: link
Be 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