Dave's Brain

Browse - programming tips - get id of current process

Date: 2011sep30
Level: beginner
Language: C/C++

Q.  How do I obtain the ID of the current process?

A.

On Windows:

	DWORD dwPid = GetCurrentProcessId();

On Linux:

	pid_t pid = getpid();

	There is also getppid() for getting your parent's ID.

Among other things, the process ID is useful for making unique temporary file names.
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: