From e710b77f13a62e01739489eaac07ca02b693909d Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Mar 31 2022 12:46:00 +0000 Subject: Fix inverted fuser exit status check The exit status of `fuser` is 0 when no processes are accessing the file. This applies to both the psmisc and busybox `fuser` implementations. The inverted check caused tmpwatch to delete used files and skip unused files. --- diff --git a/tmpwatch.c b/tmpwatch.c index e9cfb36..e340895 100644 --- a/tmpwatch.c +++ b/tmpwatch.c @@ -218,6 +218,7 @@ safe_chdir(const char *fulldirname, const char *reldirname, dev_t st_dev, } #ifdef FUSER +/* Returns 1 if filename is in use */ static int check_fuser(const char *filename) { @@ -251,7 +252,7 @@ check_fuser(const char *filename) waitpid(pid, &ret, 0); } - return (WIFEXITED(ret) && WEXITSTATUS(ret) == 0); + return (WIFEXITED(ret) && WEXITSTATUS(ret) != 0); } #else #define check_fuser(FILENAME) 0