You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Activation pattern comes from the hcsshim: https://github.com/microsoft/hcsshim/blob/v0.10.0-rc.7/cmd/containerd-shim-runhcs-v1/serve.go#L57-L70
496
+
// another way to do it would to create named pipe and pass it to the child process through handle inheritence but that would require duplicating
497
+
// the logic in Rust's 'command' for process creation. There is an issue in Rust to make it simplier to specify handle inheritence and this could
498
+
// be revisited once https://github.com/rust-lang/rust/issues/54760 is implemented.
489
499
490
500
letmut command = Command::new(cmd);
491
-
command.current_dir(cwd).envs(vars).args([
492
-
"-namespace",
493
-
&opts.namespace,
494
-
"-id",
495
-
&opts.id,
496
-
"-address",
497
-
&opts.address,
498
-
]);
501
+
command
502
+
.current_dir(cwd)
503
+
.stdout(Stdio::piped())
504
+
.stdin(Stdio::null())
505
+
.stderr(Stdio::null())
506
+
.envs(vars)
507
+
.args([
508
+
"-namespace",
509
+
&opts.namespace,
510
+
"-id",
511
+
&opts.id,
512
+
"-address",
513
+
&opts.address,
514
+
"-socket",
515
+
&address,
516
+
]);
499
517
500
518
if opts.debug{
501
519
command.arg("-debug");
502
520
}
503
521
504
-
#[cfg(unix)]
505
-
{
506
-
command
507
-
.stdout(Stdio::null())
508
-
.stdin(Stdio::null())
509
-
.stderr(Stdio::null())
510
-
.fd_mappings(vec![FdMapping{
511
-
parent_fd: _listener.into(),
512
-
child_fd:SOCKET_FD,
513
-
}])?;
514
-
515
-
command
516
-
.spawn()
517
-
.map_err(io_error!(e,"spawn shim"))
518
-
.map(|child| {
519
-
// Ownership of `listener` has been passed to child.
520
-
(child.id(), address)
521
-
})
522
-
}
523
-
522
+
// On Windows Rust currently sets the `HANDLE_FLAG_INHERIT` flag to true when using Command::spawn.
523
+
// When a child process is spawned by another process (containerd) the child process inherits the parent's stdin, stdout, and stderr handles.
524
+
// Due to the HANDLE_FLAG_INHERIT flag being set to true this will cause containerd to hand until the child process closes the handles.
525
+
// As a workaround we can Disables inheritance on the io pipe handles.
526
+
// This workaround comes from https://github.com/rust-lang/rust/issues/54760#issuecomment-1045940560
524
527
#[cfg(windows)]
525
-
{
526
-
// Activation pattern for Windows comes from the hcsshim: https://github.com/microsoft/hcsshim/blob/v0.10.0-rc.7/cmd/containerd-shim-runhcs-v1/serve.go#L57-L70
527
-
// another way to do it would to create named pipe and pass it to the child process through handle inheritence but that would require duplicating
528
-
// the logic in Rust's 'command' for process creation. There is an issue in Rust to make it simplier to specify handle inheritence and this could
529
-
// be revisited once https://github.com/rust-lang/rust/issues/54760 is implemented.
0 commit comments