Re: wait4() WNOHANG ignored when tracing under 2.0.28

J. Richard Sladkey (jrs@foliage.com)
05 Feb 1997 07:03:47 +0000


smurf@work.smurf.noris.de (Matthias Urlichs) writes:

> The following code
>
>
> /* foo.c */
> #include <sys/wait.h>
> main() {
> int pid = fork();
> int val;
>
> if(pid == 0) {
> sleep(5);
> exit(0);
> }
>
> wait4(-1,&val,WNOHANG,NULL);
> }
>
> does NOT work when traced:
>
> Ideas, anybody?

This is a longstanding bug in strace. Here is a preliminary patch:

Index: process.c
===================================================================
RCS file: /home/jrs/CVS/strace/process.c,v
retrieving revision 2.36
diff -c -r2.36 process.c
*** process.c 1996/05/19 06:40:36 2.36
--- process.c 1997/02/05 06:55:04
***************
*** 816,821 ****
--- 816,823 ----
struct tcb *tcp;
{
if (entering(tcp)) {
+ if (tcp->u_nargs >= 3 && (tcp->u_arg[2] & WNOHANG))
+ return 0;
if (tcp->nchildren > 0) {
/* There are traced children */
tcp->flags |= TCB_SUSPENDED;