Skip to content

Commit

Permalink
Workaround for the unsafe block.
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Oct 25, 2017
1 parent 7b8d932 commit 9d26b74
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,9 +83,11 @@ pub fn scan(root: &Path, pattern: Arc<Regex>, config: Arc<FdOptions>) {

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);
Expand Down

0 comments on commit 9d26b74

Please sign in to comment.