pub fn disable_core_dumps() {
#[cfg(unix)]
{
let limit = libc::rlimit {
rlim_cur: 0,
rlim_max: 0,
};
unsafe {
libc::setrlimit(libc::RLIMIT_CORE, &raw const limit);
}
}
}
#[cfg(all(test, unix))]
mod tests {
use super::*;
#[test]
fn disables_core_dumps() {
disable_core_dumps();
let mut current = libc::rlimit {
rlim_cur: 1,
rlim_max: 1,
};
let rc = unsafe { libc::getrlimit(libc::RLIMIT_CORE, &raw mut current) };
assert_eq!(rc, 0, "getrlimit failed");
assert_eq!(current.rlim_cur, 0);
assert_eq!(current.rlim_max, 0);
}
}