[Python-Dev] Best Python API for exposing posix_spawn (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Tue Jan 9 05:01:01 EST 2018


On Mon, 08 Jan 2018 09:11:38 +0000 Pablo Galindo Salgado <pablogsal at gmail.com> wrote:

Hi,

I'm currently working on exposing posixspawn in the posix module (and by extension in the os module). You can find the initial implementation in this PR: https://github.com/python/cpython/pull/5109 As pointed out by Gregory P. Smith, some changes are needed in the way the fileactions arguments is passed from Python. For context, posixspawn has the following declaration: int posixspawn(pidt *pid, const char *path, const posixspawnfileactionst *fileactions, const posixspawnattrt *attrp, char *const argv[], char *const envp[]); Here, fileactions is an object that represents a list of file actions (open, close or dup2) that is populated using helper functions on the C API. The question is: what is the best way to deal with this argument?

How about a list of tuples like: [(os.SPAWN_OPEN, 4, 'README.txt', os.O_RDONLY, 0), (os.SPAWN_CLOSE, 5), (os.SPAWN_DUP2, 3, 6), ]

I don't expect this API to be invoked directly by user code so it doesn't have to be extremely pretty.

Regards

Antoine.



More information about the Python-Dev mailing list