[PATCH 1/2] cyclictest: fix growing shm stat file

Lukas Beckmann <[email protected]>
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
On a received USR2 signal, the current statistics are written to a file
in shared memory. Before that happens, it is truncated to zero to clear
it.

However, currently the shm file keeps growing with each received signal
because the seek pointer is not updated by ftruncate.

This is fixed by calling fseek after truncating.

Signed-off-by: Lukas Beckmann <[email protected]>
---
 src/cyclictest/cyclictest.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 191945e..960c905 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1472,6 +1472,7 @@ static void sighand(int sig)
 			return;
 		}
 		rstat_ftruncate(rstat_fd, 0);
+		lseek(rstat_fd, 0, SEEK_SET);
 		quiet = 0;
 		dprintf(rstat_fd, "#---------------------------\n");
 		dprintf(rstat_fd, "# cyclictest current status:\n");
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.