os.getpid() in Bitcoin's python test scripts - What does it actually do? I was looking at ../qa/rpc-tests/util.py in order to figure out how arbitrary ports are assigned to each created node.
In the first lines of the code it says:


  ...def p2p_port(n):return 11000 + n + os.getpid()%999...


So I'm wondering what exactly os.getpid()%999 does?
Is it instantly looking for a free port?

Thanks in advance!
os.getpid() in Python is getting the current process id. The processor id is 'random-ish', in that running the entire test several times will result in a different pid, but within the same test the pid will remain constant. 

The % operator is the modulus operator, which is essentially chopping off all but the last 3 digits of the processor id. 

Together os.getpid() % 999 is getting a constant offset and ignoring all but the last 3 digits. This new 3 digit number of added to the constant 11000 to return the port number to use.