From owner-cvs-src-old@FreeBSD.ORG Mon Oct 12 15:46:30 2009 Return-Path: Delivered-To: cvs-src-old@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F87D1065796 for ; Mon, 12 Oct 2009 15:46:30 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4DAE58FC1C for ; Mon, 12 Oct 2009 15:46:30 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n9CFkUEk039728 for ; Mon, 12 Oct 2009 15:46:30 GMT (envelope-from rdivacky@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n9CFkUda039727 for cvs-src-old@freebsd.org; Mon, 12 Oct 2009 15:46:30 GMT (envelope-from rdivacky@repoman.freebsd.org) Message-Id: <200910121546.n9CFkUda039727@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to rdivacky@repoman.freebsd.org using -f From: Roman Divacky Date: Mon, 12 Oct 2009 15:46:17 +0000 (UTC) To: cvs-src-old@freebsd.org X-FreeBSD-CVS-Branch: RELENG_8 Subject: cvs commit: src/contrib/tcsh sh.c X-BeenThere: cvs-src-old@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Oct 2009 15:46:30 -0000 rdivacky 2009-10-12 15:46:17 UTC FreeBSD src repository Modified files: (Branch: RELENG_8) contrib/tcsh sh.c Log: SVN rev 197982 on 2009-10-12 15:46:17Z by rdivacky MFC r197812: Fix tcsh losing history when tcsh terminates because the pty beneath it is closed. Diagnosed by Ted Anderson: New signal queuing logic was introduced in 6.15 and allows the signal handlers to be run explicitly by calling handle_pending_signals, instead of immediately when the signal is delivered. This function is called at various places, typically when receiving a EINTR from a slow system call such as read or write. In the pty exit case, it was called from xwrite, called from flush, while printing the "exit" message after receiving EOF when reading from the pty (note that the read did not return EINTR but zero bytes, indicating EOF). The SIGHUP handler, phup(), called rechist, which opened the history file and began writing the merged history to it. This process invoked flush recursively to actually write the data. In this case, however, the flush noticed it was being called recursively and decided fail by calling stderror. My conclusion was that the signal was being handled at a bad time. But whether to fix flush not to care about the recursive call, or to handle the signal some other time and when to handle it, was unclear to me. However, by adding an extra call to handle_pending_signals, just after process() returns to main(), I was able to avoid the truncated history after network outages and similar failures. I verified this fix in version 6.17. Approved by: re (kib) Revision Changes Path 1.3.2.1 +2 -0 src/contrib/tcsh/sh.c