how to spawn a process under different user

Tim Harig usernet at
Thu Jul 2 18:27:05 EDT 2009

On 2009-07-02, sanket <sanket.s.patel at> wrote:
>> sanket wrote:
>> > I am trying to use python's subprocess module to launch a process.
>> > but in order to do that I have to change the user.
> I am using python 2.4 on centos.

I have never done this in python; but, using the normal system calls in C
the process is basically:
	1. fork() a  new process
	2. the child process changes its user id with setreuid() and
		possibly its group id with setregid()
	3. then the child exec()s new process which replaces itself

All of the necessary functions should be under the os module on POSIX
operating systems.

More information about the Python-list mailing list