Skip to content

Commit f0e095c

Browse files
committed
initial commit
1 parent 84ea3bd commit f0e095c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/safeposix/syscalls/sys_calls.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,15 @@ impl Cage {
448448
self.close_syscall(fdnum);
449449
}
450450

451-
// we grab the parent cages main threads sigset and store it at 0
452-
// this way the child can initialize the sigset properly when it establishes its
453-
// own mainthreadid
451+
// We clone the parent cage's main threads and store them and index 0
452+
// This is done since there isn't a thread established for the child Cage object yet -
453+
// And there is no threadId to store it at.
454+
// The child Cage object can then initialize and store the sigset appropriately when it establishes its own
455+
// main thread id.
454456
let newsigset = interface::RustHashMap::new();
455457
if !interface::RUSTPOSIX_TESTSUITE.load(interface::RustAtomicOrdering::Relaxed) {
456-
// we don't add these for the test suite
458+
// When rustposix runs independently (not as Lind paired with NaCL runtime) we do not handle signals
459+
// The test suite runs rustposix independently and hence we do not handle signals for the test suite
457460
let mainsigsetatomic = self
458461
.sigset
459462
.get(
@@ -468,6 +471,9 @@ impl Cage {
468471
newsigset.insert(0, mainsigset);
469472
}
470473

474+
// Initialize a new cage object to replace the current running image
475+
// We set all the ids to -1 to indicate the loading phase
476+
// We clone the fd table with the memories unmapped
471477
let newcage = Cage {
472478
cageid: child_cageid,
473479
cwd: interface::RustLock::new(self.cwd.read().clone()),
@@ -489,8 +495,8 @@ impl Cage {
489495
main_threadid: interface::RustAtomicU64::new(0),
490496
interval_timer: self.interval_timer.clone_with_new_cageid(child_cageid),
491497
};
492-
//wasteful clone of fdtable, but mutability constraints exist
493498

499+
// Insert new image with updated fd tables to be inserted in the cagetable
494500
interface::cagetable_insert(child_cageid, newcage);
495501
0
496502
}

0 commit comments

Comments
 (0)