Use SIGUSR1 rather than SIGTRAP for "allocated after fork"

Some platforma (eg ARM64) apparently generate SIGTRAP for panic abort!

See eg
  https://github.com/rust-lang/rust/pull/81858#issuecomment-840702765

This is probably a bug, but (i) we want to avoid that bug rather than
trying to fix it now and (ii) it would better to use a signal that is
less at risk of strangeness.

I grepped the rust-lang/rut codebase for SIGUSR and there were no hits.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This commit is contained in:
Ian Jackson 2021-05-13 18:38:25 +01:00
parent 8220f2f212
commit f6a4963cc8

View file

@ -46,7 +46,7 @@ impl<A> PidChecking<A> {
let actual_pid = process::id();
if require_pid != actual_pid {
unsafe {
libc::raise(libc::SIGTRAP);
libc::raise(libc::SIGUSR1);
}
}
}
@ -146,5 +146,5 @@ fn main() {
let status = run(&|| panic!("allocating to display... {}", DisplayWithHeap));
dbg!(status);
assert_eq!(status.signal(), Some(libc::SIGTRAP));
assert_eq!(status.signal(), Some(libc::SIGUSR1));
}