what is the Pythonic way to do os.execve() - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: what is the Pythonic way to do os.execve() (/thread-41255.html) |
what is the Pythonic way to do os.execve() - Skaperen - Dec-07-2023 what is the Pythonic way to do os.execve() with keyword arguments like stdout= and stderr= ? basically, i want a command to replace the existing process instead of starting a new one. the various .Popen() methods create a new process. i want the command to run in the existing process with STDOUT and/or STDERR redirection.
RE: what is the Pythonic way to do os.execve() - Gribouillis - Dec-08-2023 From the linux manual execve(2) Quote: • By default, file descriptors remain open across an execve(). RE: what is the Pythonic way to do os.execve() - Skaperen - Dec-12-2023 i've done execve() many times in my C programming. what i need to do in this little project is to invoke a command in the same process as the script invoking it. in Bash, this done by having "exec " in front of the command. i also need to direct its output to specific files. there is no such option in os.execve() to do such a redirection. i thought maybe some other method in some other module might have a "invoke in caller process" option in addition to ways to redirect. for now, i am doing the redirection using os.open() and os.dup2(). but this depends on file descriptors. |