X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fodhcp6c.c;h=8149738ade5d6d84cc88d7c14c55a8639236c232;hp=89dfd369588842fd647288598d0648d6a71e8f0d;hb=045d7158852d86a4b190267a252f32c2f15034aa;hpb=518cdfc1dbf5c61859f6faaf678e0bbed82755a6 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); } }