Skip to content

Commit 893969a

Browse files
authored
fix: let users decide what to wrap in child process command (#279)
1 parent 57db771 commit 893969a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

crates/rmcp/src/transport/child_process.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,25 @@ impl AsyncRead for TokioChildProcessOut {
6666
}
6767

6868
impl TokioChildProcess {
69+
/// Create a new Tokio child process with the given command.
70+
///
71+
/// # Manage the child process
72+
/// You can also check these issue and pr for more information on how to manage the child process:
73+
/// - [#156](https://github.com/modelcontextprotocol/rust-sdk/pull/156)
74+
/// - [#253](https://github.com/modelcontextprotocol/rust-sdk/issues/253)
75+
/// ```rust,ignore
76+
/// #[cfg(unix)]
77+
/// command_wrap.wrap(process_wrap::tokio::ProcessGroup::leader());
78+
/// #[cfg(windows)]
79+
/// command_wrap.wrap(process_wrap::tokio::JobObject);
80+
/// ```
81+
///
6982
pub fn new(command: impl Into<TokioCommandWrap>) -> std::io::Result<Self> {
7083
let mut command_wrap = command.into();
7184
command_wrap
7285
.command_mut()
7386
.stdin(std::process::Stdio::piped())
7487
.stdout(std::process::Stdio::piped());
75-
#[cfg(unix)]
76-
command_wrap.wrap(process_wrap::tokio::ProcessGroup::leader());
77-
#[cfg(windows)]
78-
command_wrap.wrap(process_wrap::tokio::JobObject);
7988
let (child, (child_stdout, child_stdin)) = child_process(command_wrap.spawn()?)?;
8089
Ok(Self {
8190
child: ChildWithCleanup { inner: child },

0 commit comments

Comments
 (0)