diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2014-10-08 01:29:12 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2014-10-08 01:29:12 +0200 |
commit | 1c3f90e3af0c3d6c8e946653169287baf5814ad4 (patch) | |
tree | 9b15e9ad8157bd8f9f697f6dc4e59146b6833c59 /Src/hist.c | |
parent | 1ffb184b46edd34d389af4e016abcaafec454d44 (diff) | |
parent | 9982ab6fb5266298c056326ed265fc8560202603 (diff) | |
download | zsh-1c3f90e3af0c3d6c8e946653169287baf5814ad4.tar.gz zsh-1c3f90e3af0c3d6c8e946653169287baf5814ad4.zip |
Merge commit '9982ab6fb5266298c056326ed265fc8560202603' into debian
This is exactly one commit after the zsh-5.0.7 and adds one missing
(and not unimportant) changelog entry for the 5.0.7 release.
Diffstat (limited to 'Src/hist.c')
-rw-r--r-- | Src/hist.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Src/hist.c b/Src/hist.c index 770d559b1..4660fd073 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2490,6 +2490,9 @@ flockhistfile(char *fn, int keep_trying) struct flock lck; int ctr = keep_trying ? 9 : 0; + if (flock_fd >= 0) + return 0; /* already locked */ + if ((flock_fd = open(unmeta(fn), O_RDWR | O_NOCTTY)) < 0) return errno == ENOENT ? 0 : 2; /* "successfully" locked missing file */ @@ -2590,7 +2593,12 @@ savehistfile(char *fn, int err, int writeflags) out = NULL; } else { int fd = open(tmpfile, O_CREAT | O_WRONLY | O_EXCL, 0600); - out = fd >= 0 ? fdopen(fd, "w") : NULL; + if (fd >=0) { + out = fdopen(fd, "w"); + if (!out) + close(fd); + } else + out = NULL; } #ifdef HAVE_FCHMOD @@ -2768,12 +2776,6 @@ lockhistfile(char *fn, int keep_trying) if (!fn && !(fn = getsparam("HISTFILE"))) return 1; -#ifdef HAVE_FCNTL_H - if (isset(HISTFCNTLLOCK) && flock_fd < 0) { - return flockhistfile(fn, keep_trying); - } -#endif - if (!lockhistct++) { struct stat sb; int fd; @@ -2786,6 +2788,11 @@ lockhistfile(char *fn, int keep_trying) # endif #endif +#ifdef HAVE_FCNTL_H + if (isset(HISTFCNTLLOCK)) + return flockhistfile(fn, keep_trying); +#endif + lockfile = bicat(unmeta(fn), ".LOCK"); /* NOTE: only use symlink locking on a link()-having host in order to * avoid a change from open()-based locking to symlink()-based. */ |