aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-15 05:12:52 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-15 05:12:52 +0000
commit309c57945254b75611da386f198992188a0da7e5 (patch)
treef4e2f578953e93d712611171cbc1fe969651c8a5 /src
parentfdb10ff0b59eaa60b66be5eed6077551d17ec331 (diff)
downloadtor-309c57945254b75611da386f198992188a0da7e5.tar
tor-309c57945254b75611da386f198992188a0da7e5.tar.gz
r11581@Kushana: nickm | 2006-12-15 00:12:24 -0500
Make PIDFile work on windows. Reported by Arrakis. svn:r9116
Diffstat (limited to 'src')
-rw-r--r--src/common/util.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 73df89267..6cd74e998 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 <io.h>
#include <direct.h>
+#include <process.h>
#else
#include <dirent.h>
#include <pwd.h>
@@ -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
}