From 9d26b74c2a855614a124ce1439b24301ec0e03f6 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Wed, 25 Oct 2017 21:33:44 +0200 Subject: [PATCH] Workaround for the `unsafe` block. See #147 --- src/walk.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/walk.rs b/src/walk.rs index f908bb4..39eb327 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -6,7 +6,7 @@ // notice may not be copied, modified, or distributed except // according to those terms. -use exec::{self, TokenizedCommand}; +use exec; use fshelper; use internal::{error, FdOptions}; use output; @@ -83,9 +83,11 @@ pub fn scan(root: &Path, pattern: Arc, config: Arc) { let out_perm = Arc::new(Mutex::new(())); - // This is safe because `cmd` will exist beyond the end of this scope. - // It's required to tell Rust that it's safe to share across threads. - let cmd = unsafe { Arc::from_raw(cmd as *const TokenizedCommand) }; + // TODO: the following line is a workaround to replace the `unsafe` block that was + // previously used here to avoid the (unnecessary?) cloning of the command. The + // `unsafe` block caused problems on some platforms (SIGILL instructions on Linux) and + // therefore had to be removed. + let cmd = Arc::new(cmd.clone()); // Each spawned job will store it's thread handle in here. let mut handles = Vec::with_capacity(threads);