Skip to content

Commit

Permalink
disable racy killing till a portable workaround is found
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmocatta committed Jan 22, 2020
1 parent d4ad84e commit d92edca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
15 changes: 6 additions & 9 deletions src/bin/constellation/main.rs
Expand Up @@ -376,8 +376,7 @@ fn main() {
palaver::process::ForkResult::Parent(child) => child,
};
unistd::close(process_listener).unwrap();
let child = std::sync::Arc::new(child);
let x = pending.write().unwrap().insert(process_id, child.clone());
let x = pending.write().unwrap().insert(process_id, ());
assert!(x.is_none());
trace.fabric(FabricOutputEvent::Init {
pid: process_id,
Expand All @@ -393,18 +392,16 @@ fn main() {
break;
}
let _ = scope.spawn(abort_on_unwind_1(move |_scope| {
let child_pid = child.pid;
match child.wait() {
Ok(palaver::process::WaitStatus::Exited(0))
| Ok(palaver::process::WaitStatus::Signaled(signal::Signal::SIGKILL, _)) => (),
wait_status => panic!("{:?}", wait_status),
}
let x = pending.write().unwrap().remove(&process_id).unwrap();
assert!(std::sync::Arc::ptr_eq(&child, &x));
drop(x);
let child = std::sync::Arc::try_unwrap(child).unwrap();
pending.write().unwrap().remove(&process_id).unwrap();
trace.fabric(FabricOutputEvent::Exit {
pid: process_id,
system_pid: nix::libc::pid_t::from(child.pid).try_into().unwrap(),
system_pid: nix::libc::pid_t::from(child_pid).try_into().unwrap(),
});
let _unchecked_error = bincode::serialize_into(
*stream_write.lock().unwrap(),
Expand All @@ -413,9 +410,9 @@ fn main() {
.map_err(map_bincode_err);
}));
}
for (&_job, pid) in pending.read().unwrap().iter() {
for (&_job, _pid) in pending.read().unwrap().iter() {
// TODO: this is racey
let _unchecked_error = pid.signal(signal::Signal::SIGKILL);
// let _unchecked_error = pid.signal(signal::Signal::SIGKILL);
}
})
.unwrap();
Expand Down
20 changes: 8 additions & 12 deletions src/lib.rs
Expand Up @@ -914,17 +914,12 @@ fn monitor_process(
// trace!("forking");
// No threads spawned between init and here so we're good
assert_eq!(palaver::thread::count(), 1); // TODO: balks on 32 bit due to procinfo using usize that reflects target not host
let old = unsafe {
signal::sigaction(
signal::SIGCHLD,
&signal::SigAction::new(
signal::SigHandler::SigDfl,
signal::SaFlags::empty(),
signal::SigSet::empty(),
),
)
.unwrap()
};
let new = signal::SigAction::new(
signal::SigHandler::SigDfl,
signal::SaFlags::empty(),
signal::SigSet::empty(),
);
let old = unsafe { signal::sigaction(signal::SIGCHLD, &new).unwrap() };
if let palaver::process::ForkResult::Parent(child) = palaver::process::fork(false).unwrap() {
unistd::close(reader).unwrap();
unistd::close(monitor_writer).unwrap();
Expand Down Expand Up @@ -1138,7 +1133,8 @@ fn monitor_process(
unistd::close(stderr_reader.unwrap()).unwrap();
}
unistd::close(stdout_reader).unwrap();
let _ = unsafe { signal::sigaction(signal::SIGCHLD, &old).unwrap() };
let new2 = unsafe { signal::sigaction(signal::SIGCHLD, &old).unwrap() };
assert_eq!(new.handler(), new2.handler());
trace!("awaiting ready");
let err = unistd::read(reader, &mut [0]).unwrap();
assert_eq!(err, 0);
Expand Down

0 comments on commit d92edca

Please sign in to comment.