From 309c57945254b75611da386f198992188a0da7e5 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Dec 2006 05:12:52 +0000 Subject: [PATCH] r11581@Kushana: nickm | 2006-12-15 00:12:24 -0500 Make PIDFile work on windows. Reported by Arrakis. svn:r9116 --- ChangeLog | 1 + src/common/util.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d82d5d694..b5123b1faa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ Changes in version 0.1.2.5-xxxx - 200?-??-?? a timely fashion. - Ongoing work on eventdns infrastructure: add dns server and ipv6 support. + - Make PIDFile work on Windows (untested). o Major bugfixes: - Fix a longstanding bug in eventdns that prevented the count of diff --git a/src/common/util.c b/src/common/util.c index 73df89267c..6cd74e9980 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -24,6 +24,7 @@ const char util_c_id[] = "$Id$"; #ifdef MS_WINDOWS #include #include +#include #else #include #include @@ -2015,16 +2016,18 @@ finish_daemon(const char *cp) void write_pidfile(char *filename) { -#ifndef MS_WINDOWS FILE *pidfile; if ((pidfile = fopen(filename, "w")) == NULL) { log_warn(LD_FS, "Unable to open \"%s\" for writing: %s", filename, strerror(errno)); } else { +#ifdef MS_WINDOWS + fprintf(pidfile, "%d\n", (int)_getpid()); +#else fprintf(pidfile, "%d\n", (int)getpid()); +#endif fclose(pidfile); } -#endif }