Diff options
Diffstat (limited to '')
| -rw-r--r-- | source/cache.c | 4 |
1 file changed, 3 insertions, 1 deletion
diff --git a/source/cache.c b/source/cache.c index 4802ab5..12151b8 100644 --- a/source/cache.c +++ b/source/cache.c @@ -202,7 +202,9 @@ static int lock_slot(struct cache_slot *slot) { struct stat held, named; - slot->lock_fd = open(slot->lock_path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + // Close-on-exec, so that a program the fill runs gets the file only + // as its stdout, and holds the lock no longer than it can write there. + slot->lock_fd = open(slot->lock_path, O_RDWR | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR); if (slot->lock_fd == -1) return errno; // An flock rather than a POSIX record lock. The descriptor is put on |
