From 6f0bddb015644b31552cbd80b66968fd154ddef6 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 22 Jan 2007 22:52:14 +0100 Subject: [PATCH] csv plugin: Fixed the initialization of `struct flock' to be portable. It didn't work on Mac OS X for example. --- src/csv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/csv.c b/src/csv.c index b22f176f..dd33ca5e 100644 --- a/src/csv.c +++ b/src/csv.c @@ -144,7 +144,7 @@ static int csv_write (const data_set_t *ds, const value_list_t *vl) char values[512]; FILE *csv; int csv_fd; - struct flock fl = { F_WRLCK, SEEK_SET, 0, 0, getpid () }; + struct flock fl; int status; if (value_list_to_filename (filename, sizeof (filename), ds, vl) != 0) @@ -183,6 +183,13 @@ static int csv_write (const data_set_t *ds, const value_list_t *vl) } csv_fd = fileno (csv); + memset (&fl, '\0', sizeof (fl)); + fl.l_start = 0; + fl.l_len = 0; /* till end of file */ + fl.l_pid = getpid (); + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + status = fcntl (csv_fd, F_SETLK, &fl); if (status != 0) { -- 2.11.0