From: Florian Forster Date: Mon, 22 Jan 2007 21:52:14 +0000 (+0100) Subject: csv plugin: Fixed the initialization of `struct flock' to be portable. X-Git-Tag: collectd-4.0.0~218 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=6f0bddb015644b31552cbd80b66968fd154ddef6;p=collectd.git csv plugin: Fixed the initialization of `struct flock' to be portable. It didn't work on Mac OS X for example. --- 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) {