1. Home
  2. Computing & Technology
  3. Python

Process Manipulation With Python's os Module

From Al Lukaszewski, for About.com

3 of 4

set<what you want>()

Along with the os module's get functions are the set functions. Many of the set functions complement the get functions, and one need usually only change the first letter. Most of the system calls are available only on Unix-like platforms, however some may be used on Windows, too.

  • setgroups(groups): Set the group access list of the current process. The argument groups is a sequence of integers specifying group identifiers. As this call involves administrative permissions, it can only be called as the root or administrative user on a Unix-like system.
  • setgid(gid): Sets the group ID of the current process.
  • setpgrp(): Creates a new process group. Where implemented, it functions by passing a system call of either setpgrp() or setpgrp(0, 0). It then returns the ID of the new group.
  • setpgid(pid, pgrp): Assigns process ID pid to process group pgrp. If both are equal, the process becomes the process leader for the group. If unequal, the process is added to an existing group. Where 0 is used for pid, the current process is used. If 0 is used for pgrp, the process specified by pid becomes a process group leader.
  • setreuid(ruid, euid): Sets the real and effective user ID of the calling process.
  • setregid(rgid, egid): Sets the real and effective group ID of the calling process.
  • setsid(): Creates a new session and returns its session ID. Session IDs are typically used for terminal devices and may be used to administer the jobs created within them.
  • setuid(uid): Sets the real user ID of the current process. Usually, this system call requires administrative (root) privileges.
This and the last listing are not all of the functions that get and set system-level information. In the next section, we will look at functions whose names do not fall neatly into these two areas.

Explore Python
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.