3939#ifndef SYS_clone3
4040# define SYS_clone3 435
4141# define CLONE_PIDFD 0x00001000
42- struct clone_args {
42+ #endif
43+
44+ // struct clone_args isn't defined in linux-lts headers, so define it here
45+ // Note that this struct is versioned by size. See linux/sched.h for details
46+ struct caml_eio_clone_args {
4347 uint64_t flags ;
4448 uint64_t pidfd ;
4549 uint64_t child_tid ;
@@ -48,11 +52,7 @@ struct clone_args {
4852 uint64_t stack ;
4953 uint64_t stack_size ;
5054 uint64_t tls ;
51- uint64_t set_tid ;
52- uint64_t set_tid_size ;
53- uint64_t cgroup ;
5455};
55- #endif
5656
5757// Make sure we have enough space for at least one entry.
5858#define DIRENT_BUF_SIZE (PATH_MAX + sizeof(struct dirent64))
@@ -178,9 +178,9 @@ static int pidfd_open(pid_t pid, unsigned int flags) {
178178
179179/* Like clone3, but falls back to fork if not supported.
180180 Also, raises exceptions rather then returning an error. */
181- static pid_t clone3_with_fallback (struct clone_args * cl_args ) {
181+ static pid_t clone3_with_fallback (struct caml_eio_clone_args * cl_args ) {
182182 int * pidfd = (int * )(uintptr_t ) cl_args -> pidfd ;
183- pid_t child_pid = syscall (SYS_clone3 , cl_args , sizeof (struct clone_args ));
183+ pid_t child_pid = syscall (SYS_clone3 , cl_args , sizeof (struct caml_eio_clone_args ));
184184
185185 if (child_pid >= 0 )
186186 return child_pid ; /* Success! */
@@ -216,7 +216,7 @@ CAMLprim value caml_eio_clone3(value v_errors, value v_actions) {
216216 CAMLlocal1 (v_result );
217217 pid_t child_pid ;
218218 int pidfd = -1 ; /* Is automatically close-on-exec */
219- struct clone_args cl_args = {
219+ struct caml_eio_clone_args cl_args = {
220220 .flags = CLONE_PIDFD ,
221221 .pidfd = (uintptr_t ) & pidfd ,
222222 .exit_signal = SIGCHLD , /* Needed for wait4 to work if we exit before exec */
0 commit comments