+fn check_err<T: std::fmt::Debug + Ord + Default>(num: T) -> Result<T> {
+ println!("check_err trying to convert {:?}", num);
+ if num < T::default() {
+ Err(Error::last_os_error())
+ } else {
+ Ok(num)
+ }
+}
+
+fn fork() -> Result<u32> {
+ check_err(unsafe { libc::fork() }).map(|pid| pid as u32)
+}
+
+fn abandon_children() -> Result<usize> {
+ let res = check_err(unsafe { libc::signal(libc::SIGCHLD, libc::SIG_IGN) });
+ println!("result from signal call with ({:?}, {:?}) is {:?} (FYI SIG_DFL={:?})", libc::SIGCHLD, libc::SIG_IGN, res, libc::SIG_DFL);
+ res
+}
+
+fn exit() -> () {
+ unsafe { libc::exit(0) }
+}
+
+