* RFA: clean up logic in linux_child_wait
@ 2001-12-07 20:05 Jim Blandy
2001-12-07 20:13 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Jim Blandy @ 2001-12-07 20:05 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
GDB still uses linux-thread.c on the S/390.
I don't think this function's callers actually noticed that it was
returning incorrect values, so this patch can't be tested, but it
wasn't analyzing things correctly.
2001-12-07 Jim Blandy <jimb@redhat.com>
* linux-thread.c (linux_child_wait): Rework logic to return proper
errno values, make it clearer that we've handled all cases, and
not depend on errno being preserved across successful system
calls.
Index: gdb/linux-thread.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/linux-thread.c,v
retrieving revision 1.17
diff -c -r1.17 linux-thread.c
*** gdb/linux-thread.c 2001/06/14 21:03:15 1.17
--- gdb/linux-thread.c 2001/12/08 04:01:45
***************
*** 1256,1306 ****
int
linux_child_wait (int pid, int *rpid, int *status)
{
! int save_errno;
/* Note: inftarg has these inside the loop. */
set_sigint_trap (); /* Causes SIGINT to be passed on to the
attached process. */
set_sigio_trap ();
! errno = save_errno = 0;
for (;;)
{
! errno = 0;
! *rpid = waitpid (pid, status, __WCLONE | WNOHANG);
! save_errno = errno;
if (*rpid > 0)
{
/* Got an event -- break out */
break;
- }
- if (errno == EINTR) /* interrupted by signal, try again */
- {
- continue;
}
! errno = 0;
*rpid = waitpid (pid, status, WNOHANG);
if (*rpid > 0)
{
/* Got an event -- break out */
break;
- }
- if (errno == EINTR)
- {
- continue;
}
! if (errno != 0 && save_errno != 0)
! {
! break;
! }
sigsuspend(&linuxthreads_block_mask);
}
clear_sigio_trap ();
clear_sigint_trap ();
! return errno ? errno : save_errno;
}
--- 1256,1364 ----
int
linux_child_wait (int pid, int *rpid, int *status)
{
! int return_errno = 0;
/* Note: inftarg has these inside the loop. */
set_sigint_trap (); /* Causes SIGINT to be passed on to the
attached process. */
set_sigio_trap ();
! /* On older Linux kernels, there's no way to say "please wait for
! both clones and normal processes." If you specify __WCLONE, you
! get clones; if you don't, you don't. Since you might miss one
! while waiting for the other, the only way to wait for both is to
! wait for SIGCHLD, and then use WNOHANG to see what happened. */
for (;;)
{
! int clone_children_exist;
+ /* Check for clones. */
+ *rpid = waitpid (pid, status, __WCLONE | WNOHANG);
+
if (*rpid > 0)
{
/* Got an event -- break out */
break;
}
+ else if (*rpid < 0)
+ {
+ /* Only when the system call fails can we make any
+ assumptions about errno's value. A successful system
+ call may still set errno to something. */
! if (errno == EINTR)
! /* interrupted by signal, try again */
! continue;
! else if (errno != ECHILD)
! {
! /* Some other error, which we should report to our
! caller. */
! return_errno = errno;
! break;
! }
!
! /* There are no clone children. It's not just that they
! exist but they don't have any status to report yet, since
! we used WNOHANG --- it's that there aren't any. */
! clone_children_exist = 0;
! }
! else
! /* Here *rpid is zero. Some clone children exist, but we used
! WNOHANG and they don't have any interesting status to
! report to us yet. Fall through and check for non-clone
! children. */
! clone_children_exist = 1;
!
! /* We didn't find any clones with interesting status; check for
! non-clones. */
*rpid = waitpid (pid, status, WNOHANG);
+
if (*rpid > 0)
{
/* Got an event -- break out */
break;
}
! else if (*rpid < 0)
! {
! /* Only when the system call fails can we make any
! assumptions about errno's value. A successful system
! call may still set errno to something. */
!
! if (errno == EINTR)
! /* interrupted by signal, try again */
! continue;
! else if (errno != ECHILD)
! {
! /* Some unexpected error, which we should report to our
! caller. */
! return_errno = errno;
! break;
! }
!
! /* There are no non-clone children. If there weren't any
! clone children either, then that's an error condition we
! should report to our caller. */
! if (! clone_children_exist)
! {
! return_errno = ECHILD;
! break;
! }
!
! /* Otherwise, we should block, since there are clone
! children. */
! }
! else
! /* Some non-clone children exist, but we used WNOHANG and they
! don't have any interesting status to report to us yet.
! Fall through and block waiting for SIGCHLD. */
! ;
!
sigsuspend(&linuxthreads_block_mask);
}
clear_sigio_trap ();
clear_sigint_trap ();
! return return_errno;
}
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: RFA: clean up logic in linux_child_wait
2001-12-07 20:05 RFA: clean up logic in linux_child_wait Jim Blandy
@ 2001-12-07 20:13 ` Daniel Jacobowitz
2001-12-08 10:14 ` Jim Blandy
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2001-12-07 20:13 UTC (permalink / raw)
To: Jim Blandy; +Cc: Michael Snyder, gdb-patches
On Fri, Dec 07, 2001 at 11:06:32PM -0500, Jim Blandy wrote:
>
> GDB still uses linux-thread.c on the S/390.
It shouldn't.
From the current sources I see:
NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o s390-nat.o linux-thread.o core-aout.o core-regset.o
# post 5.0 natdepfiles.
NATDEPFILES+= thread-db.o lin-lwp.o proc-service.o
i.e. it's actually using _both_. What dies horribly if you kill
linux-thread.o? That module is pretty severely deprecated.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: RFA: clean up logic in linux_child_wait
2001-12-07 20:13 ` Daniel Jacobowitz
@ 2001-12-08 10:14 ` Jim Blandy
2001-12-08 10:28 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Jim Blandy @ 2001-12-08 10:14 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz <drow@mvista.com> writes:
> > GDB still uses linux-thread.c on the S/390.
>
> It shouldn't.
>
> >From the current sources I see:
> NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o s390-nat.o linux-thread.o core-aout.o core-regset.o
> # post 5.0 natdepfiles.
> NATDEPFILES+= thread-db.o lin-lwp.o proc-service.o
>
> i.e. it's actually using _both_. What dies horribly if you kill
> linux-thread.o? That module is pretty severely deprecated.
Well, the only thing that dies horribly is the three testsuite
failures I was trying to resolve.
Do you want my job?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: RFA: clean up logic in linux_child_wait
2001-12-08 10:14 ` Jim Blandy
@ 2001-12-08 10:28 ` Daniel Jacobowitz
2001-12-08 19:46 ` Jim Blandy
2001-12-09 10:16 ` Andrew Cagney
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2001-12-08 10:28 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches
On Sat, Dec 08, 2001 at 01:15:24PM -0500, Jim Blandy wrote:
>
> Daniel Jacobowitz <drow@mvista.com> writes:
> > > GDB still uses linux-thread.c on the S/390.
> >
> > It shouldn't.
> >
> > >From the current sources I see:
> > NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o s390-nat.o linux-thread.o core-aout.o core-regset.o
> > # post 5.0 natdepfiles.
> > NATDEPFILES+= thread-db.o lin-lwp.o proc-service.o
> >
> > i.e. it's actually using _both_. What dies horribly if you kill
> > linux-thread.o? That module is pretty severely deprecated.
>
>
> Well, the only thing that dies horribly is the three testsuite
> failures I was trying to resolve.
>
> Do you want my job?
Sorry for my tone there.
On Oct. 14, Mark Kettenis checked in a patch that was intended to make
all Linux targets use lin-lwp instead of linux-thread. The fact that
S/390 still was afterwards was probably just an oversight; S/390 now
contains the only reference to that file out of any port.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: RFA: clean up logic in linux_child_wait
2001-12-08 10:28 ` Daniel Jacobowitz
@ 2001-12-08 19:46 ` Jim Blandy
2001-12-09 10:16 ` Andrew Cagney
1 sibling, 0 replies; 6+ messages in thread
From: Jim Blandy @ 2001-12-08 19:46 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz <drow@mvista.com> writes:
> > Well, the only thing that dies horribly is the three testsuite
> > failures I was trying to resolve.
> >
> > Do you want my job?
>
> Sorry for my tone there.
No, no, there was nothing wrong with your tone. Your suggestion was
quick, simplified the code, and relieved me of the responsibility to
track down some bugs that, at the time I posted, I had no real idea
where I was going to go with. So I'm quite grateful. The joke was
that my work might get done better if you were doing it. :)
> On Oct. 14, Mark Kettenis checked in a patch that was intended to make
> all Linux targets use lin-lwp instead of linux-thread. The fact that
> S/390 still was afterwards was probably just an oversight; S/390 now
> contains the only reference to that file out of any port.
Yeah, I figured there was some kind of history behind it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: RFA: clean up logic in linux_child_wait
2001-12-08 10:28 ` Daniel Jacobowitz
2001-12-08 19:46 ` Jim Blandy
@ 2001-12-09 10:16 ` Andrew Cagney
1 sibling, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2001-12-09 10:16 UTC (permalink / raw)
To: Daniel Jacobowitz, Jim Blandy; +Cc: gdb-patches
> On Oct. 14, Mark Kettenis checked in a patch that was intended to make
> all Linux targets use lin-lwp instead of linux-thread. The fact that
> S/390 still was afterwards was probably just an oversight; S/390 now
> contains the only reference to that file out of any port.
Probably me committing DJ Barrow's s390 changes. If someone is trying
to eliminate something, let me know and I'll add it to the ARI list.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2001-12-09 18:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-07 20:05 RFA: clean up logic in linux_child_wait Jim Blandy
2001-12-07 20:13 ` Daniel Jacobowitz
2001-12-08 10:14 ` Jim Blandy
2001-12-08 10:28 ` Daniel Jacobowitz
2001-12-08 19:46 ` Jim Blandy
2001-12-09 10:16 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox