Use getpid instead of GetCurrentProcessId as the latter calls into io-layer which is not initialzed at this point.
Use bash when using $RANDOM bashism

$RANDOM is only supported by bash, not by sh.
Merge pull request #991 from ranma42/fix-jay-sh-bashism

Use bash when using $RANDOM bashism
Merge pull request #273 from joncham/bug-getpid

Use getpid instead of GetCurrentProcessId as the latter calls into io-la...