From owner-freebsd-stable@FreeBSD.ORG Sun Jan 26 21:19:57 2014 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BC32570F for ; Sun, 26 Jan 2014 21:19:57 +0000 (UTC) Received: from mail1.yamagi.org (yugo.yamagi.org [84.201.39.245]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 80CBD1B24 for ; Sun, 26 Jan 2014 21:19:56 +0000 (UTC) Received: from p579a6fb8.dip0.t-ipconnect.de ([87.154.111.184] helo=happy.home.yamagi.org) by mail1.yamagi.org with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82 (FreeBSD)) (envelope-from ) id 1W7Wn4-0007Gn-QU; Sun, 26 Jan 2014 21:58:52 +0100 Date: Sun, 26 Jan 2014 21:58:45 +0100 From: Yamagi Burmeister To: amarat@li.ru Subject: Re: 10.0, csh history merge broken? Message-Id: <20140126215845.3b62debf03dade433622e9ba@yamagi.org> In-Reply-To: <52E0E917.3060403@li.ru> References: <52E0E917.3060403@li.ru> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.24.22; amd64-portbld-freebsd10.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: stable@freebsd.org X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jan 2014 21:19:57 -0000 Hello, this is a long standing problem. There are no locks in the csh / tcsh history merging code, thus it's racy between several shell instances. When enough shells are closed at the same time and your machine is fast enough, chances are high that several merges occure at the same time and break your ~/.history. I have this code in my ~/.logout to create a backup: # Create a backup of the history cp ${histfile} ${histfile}.bak # Create a backup of the directory stack cp ${dirsfile} ${dirsfile}.bak Please note that it is only reliable when there's only one login-shell running. Otherwise you'll need some more magic. The root cause was fixes upstream in december last year by adding the new "lock" option. If it's set, the history merge is serialized between all shell instances. The commit is here: https://github.com/tcsh-org/tcsh/commit/bb6ea8e92179d3c1b574764977f6f5e2d2ecd1e0 You'll need this one too: https://github.com/tcsh-org/tcsh/commit/0684fcc55321f6f0fca5263a5071cbe64704f1fe Maybe it would be a good idea to cherry pick those two revisions and merge then into FreeBSD, until a new tcsh version is released. Regards, Yamagi On Thu, 23 Jan 2014 14:04:07 +0400 "Marat N.Afanasyev" wrote: > as root while several user csh were running, after reboot user .history > file was corrupted: > > #+1360668026 > less /etc/ma#+136066#+136cd /usr/grep KERB * > #+1360668067 > cd /usr/src/contrib/bind9/##+1360668073ggrep -i kerboros * > #+1360668076 > grep -iR kerboros * > #+1360704099 > cd /usr/ports/www/mod_pag#+136084#+136fetch -oman sudoers > #+1361372281 > cd /usr/ports/editors/openoffice-3-devel/ > #+1361690297 > telnet 19#+13617995m#+man uh#+1#+13617995m#+man xh#+1#+13617995a#+man ehci -- Homepage: www.yamagi.org XMPP: yamagi@yamagi.org GnuPG/GPG: 0xEFBCCBCB