| 332 | } |
| 333 | |
| 334 | const spawn = ( |
| 335 | command: ChildProcess.StandardCommand, |
| 336 | spawnOptions: NodeChildProcess.SpawnOptions |
| 337 | ) => |
| 338 | Effect.callback< |
| 339 | readonly [NodeChildProcess.ChildProcess, ExitSignal], |
| 340 | PlatformError.PlatformError |
| 341 | >((resume) => { |
| 342 | const deferred = Deferred.makeUnsafe<ExitCodeWithSignal>() |
| 343 | const handle = NodeChildProcess.spawn( |
| 344 | command.command, |
| 345 | command.args, |
| 346 | spawnOptions |
| 347 | ) |
| 348 | handle.on("error", (error) => { |
| 349 | resume(Effect.fail(toPlatformError("spawn", error, command))) |
| 350 | }) |
| 351 | handle.on("exit", (...args) => { |
| 352 | Deferred.doneUnsafe(deferred, Exit.succeed(args)) |
| 353 | }) |
| 354 | handle.on("spawn", () => { |
| 355 | resume(Effect.succeed([handle, deferred])) |
| 356 | }) |
| 357 | return Effect.sync(() => { |
| 358 | handle.kill("SIGTERM") |
| 359 | }) |
| 360 | }) |
| 361 | |
| 362 | const killProcessGroup = ( |
| 363 | command: ChildProcess.StandardCommand, |