static struct procinfo *
wait_fd ()
{
- struct procinfo *pi;
+ struct procinfo *pi, *next_pi;
#ifndef LOSING_POLL
int num_fds;
int i;
attached process. */
set_sigio_trap ();
+ wait_again:
#ifndef LOSING_POLL
while (1)
{
if (0 == (poll_list[i].revents &
(POLLWRNORM | POLLPRI | POLLERR | POLLHUP | POLLNVAL)))
continue;
- for (pi = procinfo_list; pi; pi = pi->next)
+ for (pi = procinfo_list; pi; pi = next_pi)
{
+ next_pi = pi->next;
if (poll_list[i].fd == pi->ctl_fd)
{
- if (!procfs_read_status(pi))
- {
- /* The LWP has apparently terminated. */
+ num_fds--;
+ if ((poll_list[i].revents & POLLHUP) != 0 ||
+ !procfs_read_status(pi))
+ { /* The LWP has apparently terminated. */
if (info_verbose)
- printf_filtered ("LWP %d doesn't respond.\n",
+ printf_filtered ("LWP %d exited.\n",
(pi->pid >> 16) & 0xffff);
- /* could call close_proc_file here, but I'm afraid to... */
+ close_proc_file (pi);
+ if (num_fds != 0)
+ continue; /* already another event to process */
+ else
+ goto wait_again; /* wait for another event */
}
-
- num_fds--;
pi->had_event = 1;
break;
}
procfs_write_pckill (pi);
#endif /* PROCFS_NEED_PIOCSSIG_FOR_KILL */
-#ifdef PR_DEAD
- /* With Alpha OSF/1 procfs, the process remains stopped after the inferior
- gets killed. After some time, the stop reason of the inferior changes
- to PR_DEAD and a PIOCRUN ioctl must be used to finally terminate the
- process. While the stop reason has not yet changed to PR_DEAD,
- the PIOCRUN will return with EAGAIN, and we keep trying.
- Any other errors are silently ignored as the inferior might have
- died already. */
- while (procfs_read_status (pi) && (pi->prstatus.pr_flags & PR_STOPPED))
- {
- pi->prrun.pr_flags = PRCFAULT;
- if (ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) >= 0 || errno != EAGAIN)
- break;
- sleep (1);
- }
-#endif
-
close_proc_file (pi);
/* Only wait() for our direct children. Our grandchildren zombies are killed
procfs_set_inferior_syscall_traps (pip)
struct procinfo *pip;
{
-#ifndef PIOCSSPCACT
procfs_set_syscall_trap (pip, SYS_exit, PROCFS_SYSCALL_ENTRY,
procfs_exit_handler);
+#ifndef PRFS_STOPEXEC
#ifdef SYS_exec
procfs_set_syscall_trap (pip, SYS_exec, PROCFS_SYSCALL_EXIT,
procfs_exec_handler);
procfs_set_syscall_trap (pip, SYS_execve, PROCFS_SYSCALL_EXIT,
procfs_exec_handler);
#endif
-#endif /* PIOCSSPCACT */
+#endif /* PRFS_STOPEXEC */
/* Setup traps on exit from sproc() */
premptyset (&exitset.sysset);
premptyset (&entryset.sysset);
-#ifdef PIOCSSPCACT
+#ifdef PRFS_STOPEXEC
/* Under Alpha OSF/1 we have to use a PIOCSSPCACT ioctl to trace
- exits from exec system calls because of the user level loader.
- Starting with OSF/1-4.0, tracing the entry to the exit system
- call no longer works. So we have to use PRFS_STOPTERM to trace
- termination of the inferior. */
+ exits from exec system calls because of the user level loader. */
{
int prfs_flags;
gdb_flush (gdb_stderr);
_exit (127);
}
- prfs_flags |= PRFS_STOPEXEC | PRFS_STOPTERM;
+ prfs_flags |= PRFS_STOPEXEC;
if (ioctl (fd, PIOCSSPCACT, &prfs_flags) < 0)
{
perror (procname);
_exit (127);
}
}
-#else /* PIOCSSPCACT */
+#else /* PRFS_STOPEXEC */
/* GW: Rationale...
Not all systems with /proc have all the exec* syscalls with the same
names. On the SGI, for example, there is no SYS_exec, but there
gdb_flush (gdb_stderr);
_exit (127);
}
+#endif /* PRFS_STOPEXEC */
praddset (&entryset.sysset, SYS_exit);
gdb_flush (gdb_stderr);
_exit (126);
}
-#endif /* PIOCSSPCACT */
/* Turn off inherit-on-fork flag so that all grand-children of gdb
start with tracing flags cleared. */
error ("PR_SYSEXIT, unhandled system call %d", what);
}
break;
-#ifdef PR_DEAD
- case (short)PR_DEAD:
- {
- int dummy;
-
- /* The inferior process is about to terminate.
- pr_what has the process's exit or return value.
- A PIOCRUN ioctl must be used to restart the process so it
- can finish exiting. */
-
-#ifdef PROCFS_USE_READ_WRITE
- pctl.cmd = PCRUN;
- pctl.data = PRCFAULT;
- if (write (pi->ctl_fd, (char *) &pctl, sizeof (struct proc_ctl)) < 0)
-#else
- pi->prrun.pr_flags = PRCFAULT;
- if (ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) != 0)
-#endif
- perror_with_name (pi->pathname);
-
- if (wait (&dummy) < 0)
- rtnval = -1;
- statval = pi->prstatus.pr_what;
- }
- break;
-#endif
case PR_REQUESTED:
statval = (SIGSTOP << 8) | 0177;
break;
default:
error ("PIOCWSTOP, unknown why %d, what %d", why, what);
}
-/* Stop all the other threads when any of them stops. */
+ /* Stop all the other threads when any of them stops. */
{
struct procinfo *procinfo, *next_pi;