]> Repositorios git - scryer-prolog.git/commitdiff
store child process in machine state
authorBennet Bleßmann <[email protected]>
Sun, 20 Jul 2025 19:08:44 +0000 (21:08 +0200)
committerBennet Bleßmann <[email protected]>
Fri, 1 Aug 2025 18:21:36 +0000 (20:21 +0200)
src/machine/machine_state.rs
src/machine/machine_state_impl.rs
src/machine/system_calls.rs

index 7663c95269070715c660b517e8635f8c5e771157..6d583b00d3ace5629fc803697b1e1e9e5ea012e7 100644 (file)
@@ -20,9 +20,11 @@ use crate::parser::dashu::Integer;
 
 use indexmap::IndexMap;
 
+use std::collections::BTreeMap;
 use std::convert::TryFrom;
 use std::fmt;
 use std::ops::{Index, IndexMut, Range};
+use std::process::Child;
 use std::sync::Arc;
 
 pub(crate) type Registers = [HeapCellValue; MAX_ARITY + 1];
@@ -97,6 +99,7 @@ pub struct MachineState {
     pub(crate) unify_fn: fn(&mut MachineState),
     pub(crate) bind_fn: fn(&mut MachineState, Ref, HeapCellValue),
     pub(crate) run_cleaners_fn: fn(&mut Machine) -> bool,
+    pub(crate) child_processes: BTreeMap<u32, Child>,
 }
 
 impl fmt::Debug for MachineState {
index 3f14253d03e2dde95b548b76da162885df5037fc..e8b9d644bc8e2e85b24872bf1701615f89508cbf 100644 (file)
@@ -19,6 +19,7 @@ use crate::types::*;
 use indexmap::IndexSet;
 
 use std::cmp::Ordering;
+use std::collections::BTreeMap;
 use std::convert::TryFrom;
 
 impl MachineState {
@@ -67,6 +68,7 @@ impl MachineState {
             unify_fn: MachineState::unify,
             bind_fn: MachineState::bind,
             run_cleaners_fn: |_| false,
+            child_processes: BTreeMap::new(),
         }
     }
 
index d09344b026951e1880a9eb84e04cc1b543a62974..ff95d22b2b04991fd7d9a2ce015dfaff3cd77376 100644 (file)
@@ -8497,12 +8497,16 @@ impl Machine {
         match command.spawn() {
             Ok(child) => {
                 let pid = child.id();
+
+                self.machine_st.child_processes.insert(pid, child);
+
                 self.machine_st.bind(
                     pid_r
                         .as_var()
                         .expect("invalid values should have been rejected on the prolog side"),
                     fixnum_as_cell!(Fixnum::build_with(pid)),
                 );
+
                 Ok(())
             }
             Err(_) => {