#10601 Centralize all fork+exec in the scheduler.
Issue created by
jsirois
Currently we fork+exec in 2 places once the scheduler is resident in memory:
1.
pants/src/rust/engine/process_execution/src/local.rs
Lines 244 to 253 in</pantsbuild/pants/commit/05c3fd2d78814338428871ab3553985caef61e46|05c3fd2>
| fn stream<'a, 'b>( |
| ----------------------------------------------------------------- |
| &'a mut self, |
| req: &Process, |
| ) -> Result<BoxStream<'b, Result<ChildOutput, String>>, String> { |
| self |
| .inner |
| .stdin(Stdio::null()) |
| .stdout(Stdio::piped()) |
| .stderr(Stdio::piped()) |
| .spawn() |
2.
pants/src/rust/engine/process_execution/src/nailgun/nailgun_pool.rs
Lines 285 to 307 in</pantsbuild/pants/commit/05c3fd2d78814338428871ab3553985caef61e46|05c3fd2>
| impl NailgunProcess { |
| ---------------------------------------------------------------------- |
| fn start_new( |
| name: NailgunProcessName, |
| startup_options: Process, |
| workdir_path: &PathBuf, |
| nailgun_server_fingerprint: NailgunProcessFingerprint, |
| build_id: String, |
| ) -> Result<NailgunProcess, String> { |
| let cmd = startup_options.argv[0].clone(); |
| // TODO: This is an expensive operation, and thus we info! it. |
| // If it becomes annoying, we can downgrade the logging to just debug! |
| info!( |
| "Starting new nailgun server with cmd: {:?}, args {:?}, in cwd {:?}", |
| cmd, |
| &startup_options.argv[1..], |
| &workdir_path |
| ); |
| let handle = std:
processCommand:new(&cmd) |
| .args(&startup_options.argv[1..]) |
| .stdout(Stdio::piped()) |
| .stderr(Stdio::piped()) |
| .current_dir(&workdir_path) |
| .spawn(); |
This needs to be centralized to continue to confidently support a fix for ETXTBSY when launching user processes that have the binary as part of their input digest (
#10507). For now we are getting by by relying on the fact that the second place above - in the
process_execution::nailgun
module - is not used / dead code in practice.
pantsbuild/pants