[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#208810: Updated info (and solution)



The problem is actually not in find, it's in ash. When invoked from hw-detect
as (e.g.)

  find /lib/modules/2.4.21-5-386/kernel/ | grep -q ide-scsi

grep exits before reading the entire output from find, and find gets killed
with SIGPIPE. Normally, this would not be a problem (ash would see that the
child was killed with SIGPIPE, and thus not print out anything), but the
following lines in shell/ash.c (around line 6700) seem very wrong to me:

                st = WSTOPSIG(status);
#if JOBS
                if (!WIFSTOPPED(status))
                        st = WTERMSIG(status);
#endif
                if (sigonly) {
                        if (st == SIGINT || st == SIGPIPE)
                                goto out;
                        if (WIFSTOPPED(status))
                                goto out;
                }

If the shell is compiled with -DJOBS, this is all fine -- find wasn't stopped
(it was killed), so it correctly uses WTERMSIG instead of WSTOPSIG. However,
if the shell _isn't_ compiled with -DJOBS (which it isn't in d-i), only
WSTOPSIG is used, which extracts the high byte instead of the low byte from
the status code.  Since the status code is 13 (SIGPIPE), "st" suddenly gets
the value 0, which is equivalent to SIGEXIT. Thus, ash prints out "EXIT" on
find's exit.

The solution (at least to me) seems to be replacing the first five lines by

                st = WTERMSIG(status);
#if JOBS
                if (WIFSTOPPED(status))
                        st = WSTOPSIG(status);
#endif

which seems logical, and fixes the problem for me.

/* Steinar */
-- 
Homepage: http://www.sesse.net/




Reply to: