He meant oops 0, oops 177.

Depending on the system it can take several iterations before the
problem demonstrates itself. I would recommend trying a higher sequence
than 200 if the problem does not occur immediately.

treasure:~ # ksh
treasure:/root # echo ${.sh.version}
Version JM 93t+ 2010-02-14
treasure:/root # let n=0; for d in $(seq 1 10000); do if echo foo | grep
bar; then echo oops $((n++)); fi; done
treasure:/root # trap "" CHLD
treasure:/root # let n=0; for d in $(seq 1 10000); do if echo foo | grep
bar; then echo oops $((n++)); fi; done
oops 0                                        
oops 1
treasure:/root # 

-- 
Jared H. Hudson
Dedicated Support Engineer
[email protected] 
479-657-4309 Office
479-283-4677 Cellular

On Mon, 2010-04-05 at 14:03 -0400, Glenn Fowler wrote:
> what in the example code prints "bang"?
> 
> On Mon, 29 Mar 2010 11:08:37 +0200 Dr. Werner Fink wrote:
> > I've just become owner of a bug report reporting a flaky behaviour
> > in handling traps on SIGCHLD.  For a simply test see
> 
> >  ksh> echo ${sh.version}
> >  Version JM 93t+ 2010-02-14
> >  ksh> trap "" CHLD
> >  let n=0; for d in $(seq 1 200); do if echo foo | grep bar; then echo oops 
> > $((n++)); fi; done
> >  bang 0
> >  [...]
> >  bang 177
> >  ksh>
> 
> > and repeating the loop results in different numbers of reports
> > showing that there is a race as there should no report at all.
> 
> > Beside this setting the trap to something not empty works like
> 
> >  ksh> trap ";" CHLD
> >  let n=0; for d in $(seq 1 200); do if echo foo | grep bar; then echo oops 
> > $((n++)); fi; done
> >  ksh>
> 
> > which is very strange.  It is very common to use an
> > empty string for traps used for ignoring signals, though.
> 
> >        Werner
> 
> > -- 
> >   "Having a smoking section in a restaurant is like having
> >           a peeing section in a swimming pool." -- Edward Burr
> > _______________________________________________
> > ast-users mailing list
> > [email protected]
> > https://mailman.research.att.com/mailman/listinfo/ast-users




_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to