Get current process ID

Is there a JUCE function to get the current process ID? I had a look at SystemStats and Process but didn’t find anything there.

It should be rather easy to implement using GetCurrentProcessId on Windows and getpid on OS X (and probably Linux) but I thought that it maybe is already available in JUCE or if not, it might be a useful addition.

No.. Don't think I ever added one of those. I guess because it's generally not very useful as a value except in very platform-specific code, where you don't need a cross-platform way of getting it.

It's different from the current thread ID, which is useful in its own right as a unique value to tell threads apart. In a process, you generally don't care what the process ID is because all your code would see the same number.

I agree with your point of view. But the PID can be very useful when using broadcast udp so that the process does not receive its own messages.

Can’t you just use a random number generated at the start of your app? Every process would receive a unique number this way.

In fact, that’s what I’m doing now. The PID can be useful in various applications and for a better cross-platform implementation it would be nice to have it. So I created a multiplatform library, using Juce of course. By integrating all the little functions I was missing on Android, Linux, Mac and Windows, etc. I’ve been using Juce since 2014 and I really like it.