@@ -80,6 +80,9 @@ mod sched_linux_like {
80
80
CLONE_NEWNET ;
81
81
/// The new process shares an I/O context with the calling process.
82
82
CLONE_IO ;
83
+ /// Allocates a child process file descriptor (O_CLOEXEC)
84
+ /// for the `child_tid` argument.
85
+ CLONE_PIDFD ;
83
86
}
84
87
}
85
88
@@ -109,13 +112,28 @@ mod sched_linux_like {
109
112
stack : & mut [ u8 ] ,
110
113
flags : CloneFlags ,
111
114
signal : Option < c_int > ,
115
+ parent_tid : Option < Pid > ,
116
+ tls : Option < & mut [ u8 ] > ,
117
+ child_tid : Option < Pid > ,
112
118
) -> Result < Pid > {
113
119
extern "C" fn callback ( data : * mut CloneCb ) -> c_int {
114
120
let cb: & mut CloneCb = unsafe { & mut * data } ;
115
121
( * cb) ( ) as c_int
116
122
}
117
123
118
124
let combined = flags. bits ( ) | signal. unwrap_or ( 0 ) ;
125
+ let parent_tid = match parent_tid {
126
+ Some ( mut ptid) => & mut ptid as * mut Pid ,
127
+ _ => std:: ptr:: null_mut ( ) ,
128
+ } ;
129
+ let tls = match tls {
130
+ Some ( s) => s. as_mut_ptr ( ) ,
131
+ _ => std:: ptr:: null_mut ( ) ,
132
+ } ;
133
+ let child_tid = match child_tid {
134
+ Some ( mut ctid) => & mut ctid as * mut Pid ,
135
+ _ => std:: ptr:: null_mut ( ) ,
136
+ } ;
119
137
let res = unsafe {
120
138
let ptr = stack. as_mut_ptr ( ) . add ( stack. len ( ) ) ;
121
139
let ptr_aligned = ptr. sub ( ptr as usize % 16 ) ;
@@ -130,6 +148,9 @@ mod sched_linux_like {
130
148
ptr_aligned as * mut c_void ,
131
149
combined,
132
150
& mut cb as * mut _ as * mut c_void ,
151
+ parent_tid,
152
+ tls,
153
+ child_tid,
133
154
)
134
155
} ;
135
156
0 commit comments