Replace syscall::clone() with libc::fork().

This commit is contained in:
4lDO2
2022-07-18 16:19:28 +02:00
parent 1668052a1c
commit c930dfdc08
3 changed files with 13 additions and 3 deletions
Generated
+7
View File
@@ -12,9 +12,16 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
name = "ipcd"
version = "0.1.0"
dependencies = [
"libc",
"redox_syscall",
]
[[package]]
name = "libc"
version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "redox_syscall"
version = "0.2.16"
+2 -1
View File
@@ -3,4 +3,5 @@ edition = "2018"
name = "ipcd"
version = "0.1.0"
[dependencies]
redox_syscall = "0.2.12"
libc = "0.2"
redox_syscall = "0.2"
+4 -2
View File
@@ -20,8 +20,10 @@ const TOKEN_CHAN: usize = 0;
const TOKEN_SHM: usize = 1;
fn main() -> Result<(), Box<dyn std::error::Error>> {
if unsafe { syscall::clone(CloneFlags::empty()) }.map_err(from_syscall_error)? != 0 {
return Ok(());
match unsafe { libc::fork() } {
0 => (),
-1 => return Err(Box::new(io::Error::last_os_error())),
_child => return Ok(()),
}
// Create event listener for both files