[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9116: Make PIDFile work on windows. Reported by Arrakis. (in tor/trunk: . src/common)



Author: nickm
Date: 2006-12-15 00:12:52 -0500 (Fri, 15 Dec 2006)
New Revision: 9116

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/util.c
Log:
 r11581@Kushana:  nickm | 2006-12-15 00:12:24 -0500
 Make PIDFile work on windows.  Reported by Arrakis.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11581] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-12-15 05:12:42 UTC (rev 9115)
+++ tor/trunk/ChangeLog	2006-12-15 05:12:52 UTC (rev 9116)
@@ -13,6 +13,7 @@
       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

Modified: tor/trunk/src/common/util.c
===================================================================
--- tor/trunk/src/common/util.c	2006-12-15 05:12:42 UTC (rev 9115)
+++ tor/trunk/src/common/util.c	2006-12-15 05:12:52 UTC (rev 9116)
@@ -24,6 +24,7 @@
 #ifdef MS_WINDOWS
 #include <io.h>
 #include <direct.h>
+#include <process.h>
 #else
 #include <dirent.h>
 #include <pwd.h>
@@ -2015,16 +2016,18 @@
 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
 }