The os module also offers functions to find important information about your location or about the process. Note that almost all of these are available only on Unix-like systems, not Windows. I have indicated below where they are available on non-Unix platforms.
- getcwd(): Returns the current working directory.
- getcwdu(): Same as getcwd() except the returned string is in Unicode.
- getegid(): Returns the 'effective group ID'. On Unix, processes may have both effective and real group IDs. Note(): Real and effective IDs are usually the same, but sometimes they are not. If you do not know that you need to address these matters, you probably don't.
- geteuid(): Returns the 'effective user ID'.
- getgid(): Returns the 'real group ID' of the process.
- getgroups(): Returns the real group ID of the process.
- getpgid(pid): Returns the process group ID, taking the process ID (pid) of that process as an argument. If the pid is 0, the process group of the calling process is returned.
- getpgrp(): Returns the ID of the current process group. Note that the process group is not necessarily the same as the group ID of the process. Process groups typically pertain to job control, not group ID.
- getpid(): Returns the real process ID of the current process. This is available under both Unix and Windows.
- getppid(): Returns the process ID of the parent process.
- getsid(pid): Like getpgid(), this takes the pid of a process as an argument. It then returns the process session identifier of that process. If given 0 as an argument, information on the cureent process is returned.
- getuid(): Returns the real user ID of the current process.
More on process IDs can be read on About.com's Linux site.
