process-util: add clone_with_nested_stack() helper

This wraps glibc's clone() but deals with the 'stack' parameter in a
sensible way. Only supports invocations without CLONE_VM, i.e. when
child is a CoW copy of parent.
This commit is contained in:
Lennart Poettering
2023-06-23 10:00:30 +02:00
parent 09f9530baf
commit 29c3520f28
2 changed files with 37 additions and 0 deletions
+2
View File
@@ -139,6 +139,8 @@ void reset_cached_pid(void);
int must_be_root(void);
pid_t clone_with_nested_stack(int (*fn)(void *), int flags, void *userdata);
typedef enum ForkFlags {
FORK_RESET_SIGNALS = 1 << 0, /* Reset all signal handlers and signal mask */
FORK_CLOSE_ALL_FDS = 1 << 1, /* Close all open file descriptors in the child, except for 0,1,2 */