From 975df87d6beb28861612a814fb638ac3f4774245 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 17 Dec 2015 00:15:18 +0100 Subject: [PATCH] Update unit test for pidfile() Add ocular verification step for mtime update when pidfile() is called more than once. Signed-off-by: Joachim Nilsson --- pidfilefn.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pidfilefn.c b/pidfilefn.c index 5ba8af5..6e2b104 100644 --- a/pidfilefn.c +++ b/pidfilefn.c @@ -142,6 +142,8 @@ static void sigalrm_handler(int signo) int main(void) { + char cmd[80]; + snprintf(PIDFILE, sizeof(PIDFILE), "%s%s.pid", _PATH_VARRUN, __progname); signal(SIGTERM, sigterm_handler); @@ -157,6 +159,13 @@ int main(void) printf("Reading pid file, should be %d ...\n", getpid()); printf("=> %d\n", pidfile_read(PIDFILE)); + /* Occular verification that calling pidfile() again updates mtime */ + snprintf(cmd, sizeof(cmd), "ls -l --full-time %s", PIDFILE); + system(cmd); + printf("Before ^^ pidfile() vv after ...\n"); + pidfile(NULL); + system(cmd); + printf("Signalling ourselves ...\n"); return pidfile_signal(PIDFILE, SIGTERM);