diff --git a/rust/chg/src/clientext.rs b/rust/chg/src/clientext.rs --- a/rust/chg/src/clientext.rs +++ b/rust/chg/src/clientext.rs @@ -42,6 +42,11 @@ I: IntoIterator, P: AsRef; + /// Changes the process title of the server. + fn set_process_name

(self, name: P) -> OneShotRequest + where + P: AsRef; + /// Changes the umask of the server process. fn set_umask(self, mask: u32) -> OneShotRequest; @@ -94,6 +99,13 @@ OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars)) } + fn set_process_name

(self, name: P) -> OneShotRequest + where + P: AsRef, + { + OneShotRequest::start_with_args(self, b"setprocname", name.as_ref().as_bytes()) + } + fn set_umask(self, mask: u32) -> OneShotRequest { let mut args = BytesMut::with_capacity(mem::size_of_val(&mask)); args.put_u32_be(mask); diff --git a/rust/chg/src/locator.rs b/rust/chg/src/locator.rs --- a/rust/chg/src/locator.rs +++ b/rust/chg/src/locator.rs @@ -196,6 +196,17 @@ Ok((loc, client)) }) .and_then(|(loc, client)| { + // It's purely optional, and the server might not support this command. + if client.server_spec().capabilities.contains("setprocname") { + let fut = client + .set_process_name(format!("chg[worker/{}]", loc.process_id)) + .map(|client| (loc, client)); + Either::A(fut) + } else { + Either::B(future::ok((loc, client))) + } + }) + .and_then(|(loc, client)| { client .set_current_dir(&loc.current_dir) .map(|client| (loc, client))