Python Forum
what i would like to add to subprocess.Popen()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what i would like to add to subprocess.Popen()
#1
what i would like to add to subprocess.Popen():

something i often did when coding in C that is not convenient in Python is changing the working directory or other setting in the forked child process before calling exec*() to start a new executable. perhaps that execution needed to be done in that context. or, perhaps, that context was needed to find that executable file. the code, in POSIX, would call fork() and then in the child process it would call chdir() with the appropriate directory and finally call exec*(). i could do this in Python. but i would prefer to do this using Python tools like subprocess.Popen(). but there is no means to run some specific code between fork() and exec*() in the child process and no means to supply a directory path name for it to do a chdir() with.

i would like to see subprocess.Popen() improved to have these capabilities. an option chdir= would pass a string (str or bytes) of the path to a directory to change to. the call would exit the child and raise the appropriate exception if the chdir() fails. another keyword argument would have a name like precall= and would refer to a function to be called in the child process before exec*() is called.

i do not know if these calls would be appropriate for platforms other than POSIX.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
what i would like to add to subprocess.Popen() - by Skaperen - Aug-21-2023, 08:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pipe(s) in = subprocess.Popen() Skaperen 0 1,835 Feb-13-2021, 11:48 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020