MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / spawn_worker

Function spawn_worker

src/extraction_worker.rs:462–490  ·  view source on GitHub ↗
(self_path: &Path, token: &[u8; TOKEN_LEN])

Source from the content-addressed store, hash-verified

460}
461
462fn spawn_worker(self_path: &Path, token: &[u8; TOKEN_LEN]) -> io::Result<WorkerHandle> {
463 let token_hex = hex::encode(token);
464 let mut child = Command::new(self_path)
465 .arg(WORKER_SUBCOMMAND)
466 .env(TOKEN_ENV_VAR, token_hex)
467 .stdin(Stdio::piped())
468 .stdout(Stdio::piped())
469 .stderr(Stdio::inherit())
470 .spawn()?;
471 let stdin = child
472 .stdin
473 .take()
474 .ok_or_else(|| io::Error::other("stdin unexpectedly None despite Stdio::piped"))?;
475 let stdout = child
476 .stdout
477 .take()
478 .ok_or_else(|| io::Error::other("stdout unexpectedly None despite Stdio::piped"))?;
479 let mut stdin = BufWriter::new(stdin);
480 let stdout = BufReader::new(stdout);
481
482 stdin.write_all(token)?;
483 stdin.flush()?;
484
485 Ok(WorkerHandle {
486 stdin: Some(stdin),
487 stdout,
488 child,
489 })
490}
491
492// =============================================================================
493// Wire format: 4-byte LE length prefix + bincode payload

Callers 2

newMethod · 0.85
worker_threadFunction · 0.85

Calls 3

spawnMethod · 0.45
takeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected