From: Guus Sliepen Date: Wed, 14 Feb 2007 09:32:16 +0000 (+0000) Subject: Close the proper filedescriptor (if it exists). X-Git-Tag: import-tinc-1.1~676 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=ab6f76f6a9fc8028fff96322a52b770710ffa1a9;p=meshlink Close the proper filedescriptor (if it exists). --- diff --git a/lib/pidfile.c b/lib/pidfile.c index 08d96dfe..830d3f35 100644 --- a/lib/pidfile.c +++ b/lib/pidfile.c @@ -85,12 +85,11 @@ pid_t write_pid (char *pidfile) pid_t pid; if ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1) { - close(fd); return 0; } if ((f = fdopen(fd, "r+")) == NULL) { - fclose(f); + close(fd); return 0; }