Skip to content

wet_process: Reuse custom_env and fdstr

Daniel Stone requested to merge daniels/weston:wet-process-6-custom-env into main

[this MR is part of the same work sequence as !932 (closed) but contains no commits from it; it does not depend on either !941 (closed) or !951 (closed) or any other MR; whilst merging this will cause conflicts with the above two and vice-versa, they may be picked in any order]

This merge request takes the custom_env and fdstr helpers introduced to help with forking child processes in !947 (merged), adds them to shared/, adds some tests, and uses them in other places where we fork clients.

To support desktop-shell's behaviour of parsing a combined ENV=foo /path/to/thing --bar string into environment + exec path + args, custom_env is adapted to take args as well as environment variables. Not only does this let us delete the now-duplicate code to construct an environment for execve(), it also points to a better solution for some later commits in !932 (closed). Specifically, rather than having wet_process_create() take a pointer to a function which will return an args array as well as a 'run this in the child process space' hook to handle cloexec, it may be cleaner for wet_process_create() to be able to accept a custom_env + fdstr[] combination from the caller. (This is not currently implemented.)

At the end of this MR, weston_client_launch() through using these helpers now becomes safe wrt behaviour between fork() and exec() by not making any unsafe calls. This brings the some of the benefits of the new Xwayland client-forking behaviour introduced in !947 (merged) into common code, and makes it easier for the rest to reuse as more parts of !932 (closed) are landed.

Merge request reports