1/* @ajax/mesh-spawn: starting worker processes (mesh-host native.rs spawn,
2 * pipe, describe, exit_word). posix_spawn, not fork: a fork of meshd copies
3 * the page tables of its GPU mappings under the mm lock (5-12 ms measured on
4 * dgx-00, stalling every other thread); posix_spawn does not. */
5#ifndef MESH_SPAWN_H
6#define MESH_SPAWN_H
78#include <stdbool.h>
9#include <stddef.h>
10#include <stdint.h>
11#include <sys/types.h>
1213/* A pipe, both ends close-on-exec: fds[0] read, fds[1] write. */
14bool mesh_pipe_cloexec(int fds[2], char **err);
1516/* One (parent fd, child fd) for mesh_spawn. */
17typedef struct {
18 int parent, child;
19} mesh_spawn_fd;
2021/* posix_spawnp of argv (NULL-terminated) with this process's environment plus
22 * env ("K=V" entries, NULL-terminated, overriding), each fds pair dup2'd in
23 * (every other descriptor stays closed: they are close-on-exec), in a process
24 * group of its own (a terminal's ^C goes to meshd). False with *err:
25 * "posix_spawn <argv0>: <why>". */
26bool mesh_spawn(char *const *argv, char *const *env, const mesh_spawn_fd *fds, size_t nfds, pid_t *pid, char **err);
2728/* "exit 3", "signal 9 (Killed)", "signal 6 (Aborted), core dumped" (malloc'd). */
29char *mesh_describe_status(int status);
30/* P_EXIT's encoding: status << 8 | signal. */
31uint32_t mesh_exit_word(int status);
32/* A wait status that is a clean exit 0. */
33bool mesh_status_success(int status);
3435#endif