Bug 84059 - zsh shells' history file is sometimes truncated (race condition when killing shells)
Summary: zsh shells' history file is sometimes truncated (race condition when killing ...
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 1.3.2
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-27 00:08 UTC by Samuel Krempp
Modified: 2008-01-16 02:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Krempp 2004-06-27 00:08:56 UTC
Version:            (using KDE KDE 3.2.2)
Installed from:    Debian testing/unstable Packages
OS:                Linux

It happened many, many times when I shut the computer after many hours of work with half a dozen zsh shells inside konsole sessions.

Sometimes, when I restart, the history file shows all the commands of all the shells were saved (as it should, I think zsh takes care of saving all its instances history to a single file)

But sometimes, the history file is truncated (losing command lines of even previous days), and my homedir shows a few empty $HISTFILE.<pidnumbers> files.

My conclusion is this : 
the truncation means the zsh process is killed while re-writing the history file (it has to rewrite, since some older entries are discarded it cannot just append).
I think konsole doesnt give enough time to the zsh processes to handle its history file before killing them.

Could it be possible for the user to customize the delay before the shells are killed ? I'd even allow my shells to prevent shutdown until they saved their data if I could..
I think it is the only right solution, since the required delay varies drastically depending on how the user wants his shell to handle history.
Personnally I want it to store *many* (100.000) lines, and I had set HIST_EXPIRE_DUPS_FIRST, so that old duplicate commands are expired first.
(now I removed this option, hopefully it will make it save the history faster enough..)
I put great value in history features, and I wouldn't mind giving my zsh all the time they need to handle my history, only konsole does not know about that..
Comment 1 Kurt Hindenburg 2004-07-04 10:39:38 UTC
Not sure this is the cause...

In Konsole::~Konsole, 
    // Wait a bit for all childs to clean themselves up.
#if KDE_VERSION >=306
   while(sessions.count() && KProcessController::theKProcessController->waitForProcessExit(1))

If I understand this correctly, this allows a 1 second timeout for each process to exit.
1. Change the 1 to a higher # such as 15 or 30...
2. Change it to -1, which means no timeout.  Not sure what would happen if the process never exits...
Comment 2 Robert Knight 2007-12-11 04:47:29 UTC
Is this still a problem in current versions of Konsole?
Comment 3 Robert Knight 2008-01-16 02:02:56 UTC
Closing for two reasons:

1) There has not been a response to the above comment.

2) In KDE 4.1 the process is asked nicely to exit without a timeout being given so it should be able to take several seconds for the cleanup if necessary.