summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2023-08-19 21:57:04 -0700
committerMark Adler <madler@alumni.caltech.edu>2023-08-19 22:00:22 -0700
commitfb4222c4f7afc0b70c403849a519a0bce3deafec (patch)
tree2a33562890022ad5aae8220736a710f8bcc1d274
parent907ca0763be4547a9b0cce8c1057217488149744 (diff)
downloadpigz-fb4222c4f7afc0b70c403849a519a0bce3deafec.tar.gz
Put modification times in the gzip header only for regular files.
This replicates the behavior of gzip since version 1.10. The intent is to make piped applications of pigz produce deterministic output. Note that input redirected from a regular file is still a regular file.
-rw-r--r--pigz.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/pigz.c b/pigz.c
index c82c1eb..a771125 100644
--- a/pigz.c
+++ b/pigz.c
@@ -3922,8 +3922,8 @@ local void process(char *path) {
vstrcpy(&g.inf, &g.inz, 0, "<stdin>");
g.ind = 0;
g.name = NULL;
- g.mtime = g.headis & 2 ?
- (fstat(g.ind, &st) ? time(NULL) : st.st_mtime) : 0;
+ g.mtime = (g.headis & 2) && fstat(g.ind, &st) == 0 &&
+ S_ISREG(st.st_mode) ? st.st_mtime : 0;
len = 0;
}
else {