* [PATCH RFA] Retry open of /proc/PID/ctl in procfs.c
@ 2001-04-13 1:14 Kevin Buettner
[not found] ` <3AD77C7C.C9D4037C@cygnus.com>
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Buettner @ 2001-04-13 1:14 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-04-13 16:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-13 1:14 [PATCH RFA] Retry open of /proc/PID/ctl in procfs.c Kevin Buettner
[not found] ` <3AD77C7C.C9D4037C@cygnus.com>
2001-04-13 16:12 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox