Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: need info about attachtty hanging



On Apr 13, 12:43am, Richard J. Coleman wrote:
} Subject: need info about attachtty hanging
}
} Several people have report zsh hanging in attachtty.

Not hanging -- infinite-looping.  Not quite the same.

} Peter sent in a patch that changes
} 
} if (kill(pgrp, 0) == -1)
} 
} to
} 
} if (pgrp != mypgrp && kill(pgrp, 0) == -1)
} 
} Now I'm trying to understand what is going on.

Zsh gets EOF because the tty closes.  Ignoreeof is set, so it keeps
reading input.  attachtty() is called to make the top-level shell
the foreground process on the tty, which fails.  Without the fix
above, attachtty() calls itself recursively, which fails again;
attachtty() has no automatic variables, so it doesn't consume any
stack space, and thus the recursion is infinite.

} 1) Where is attachtty being called from when it
}    hanges (init_io, init_signals, etc...)?

My guess is it's from setterm() via refresh(), but it could be from
getkey() via any number of zle entry points.  It doesn't really
make any difference; the fix above is needed no matter what.

Note that the "ep" static protects against such recursion in the
case where the initial kill() fails.  The only time the kill() can
possibly fail is from entersubsh(), bin_fg(), or bin_read(), so
none of those is involved in this case.

} 2) Does anyone know why the original call to set the
}    foreground process is failing?

Yeah:  because the tty is closed -- the xterm window (or equivalent)
has gone away.  *No* process can have that controlling terminal any
longer.

-- 
Bart Schaefer                     Vice President, Technology, Z-Code Software
schaefer@xxxxxxxxxx                  Division of NCD Software Corporation
http://www.well.com/www/barts




Messages sorted by: Reverse Date, Date, Thread, Author