part 2: don’t stop using the history if the file has been truncated
This commit is contained in:
parent
bfa79a4e4b
commit
c203e7c5b2
11
histrap.c
11
histrap.c
@ -27,7 +27,7 @@
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.163 2017/08/07 20:40:57 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.164 2017/08/07 20:43:00 tg Exp $");
|
||||
|
||||
Trap sigtraps[ksh_NSIG + 1];
|
||||
static struct sigaction Sigact_ign;
|
||||
@ -963,10 +963,11 @@ writehistfile(int lno, const char *cmd)
|
||||
mksh_lockfd(histfd);
|
||||
sizenow = lseek(histfd, (off_t)0, SEEK_END);
|
||||
if (sizenow < histfsize) {
|
||||
/* the file has shrunk; give up */
|
||||
goto bad;
|
||||
}
|
||||
if (
|
||||
/* the file has shrunk; trust it just appending the new data */
|
||||
/* well, for now, anyway… since mksh strdups all into memory */
|
||||
/* we can use a nicer approach some time later… */
|
||||
;
|
||||
} else if (
|
||||
/* ignore changes when the file is too large */
|
||||
sizenow <= MKSH_MAXHISTFSIZE
|
||||
&&
|
||||
|
Loading…
x
Reference in New Issue
Block a user