diff options
author | Steven Barth <steven@midlink.org> | 2014-11-28 10:20:35 +0100 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2014-11-28 10:20:35 +0100 |
commit | 045d7158852d86a4b190267a252f32c2f15034aa (patch) | |
tree | b1b5b99a62abee71393bbde664f4f0628f0c6613 /src | |
parent | 518cdfc1dbf5c61859f6faaf678e0bbed82755a6 (diff) | |
download | odhcp6c-045d7158852d86a4b190267a252f32c2f15034aa.tar.gz |
Cleanup pidfile-gerneration
Diffstat (limited to 'src')
-rw-r--r-- | src/odhcp6c.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 89dfd36..8149738 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -254,19 +254,15 @@ int main(_unused int argc, char* const argv[]) return 4; } - char pidbuf[128]; if (!pidfile) { - snprintf(pidbuf, sizeof(pidbuf), - "/var/run/odhcp6c.%s.pid", ifname); - pidfile = pidbuf; + snprintf((char*)buf, sizeof(buf), "/var/run/odhcp6c.%s.pid", ifname); + pidfile = (char*)buf; } - int fd = open(pidfile, O_WRONLY | O_CREAT, 0644); - if (fd >= 0) { - char buf[8]; - int len = snprintf(buf, sizeof(buf), "%i\n", getpid()); - write(fd, buf, len); - close(fd); + FILE *fp = fopen(pidfile, "w"); + if (fp) { + fprintf(fp, "%i\n", getpid()); + fclose(fp); } } |