Skip to content

Commit

Permalink
Fix getpid() usage on Windows
Browse files Browse the repository at this point in the history
On Windows, getpid() is _getpid(), and requires that we first include
<process.h>.  arc4random.c previously didn't know that.

Actually, I question whether arc4random needs to do its getpid() tricks
on Windows.  They exist only so that we remember to re-seed the ARC4
cipher whenever we fork... but Windows has no fork(), so I think we're
in the clear.
  • Loading branch information
nmathewson committed Feb 18, 2010
1 parent cb52838 commit ff2a134
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions arc4random.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#ifndef ARC4RANDOM_NO_INCLUDES
#ifdef WIN32
#include <wincrypt.h>
#include <process.h>
#else
#include <fcntl.h>
#include <unistd.h>
Expand Down Expand Up @@ -216,6 +217,10 @@ arc4_stir(void)
arc4_count = BYTES_BEFORE_RESEED;
}

#ifdef WIN32
#define getpid _getpid
#endif

static void
arc4_stir_if_needed(void)
{
Expand Down

0 comments on commit ff2a134

Please sign in to comment.