Implement Sync for `process::Command on unix and vxworks

This commit is contained in:
LeSeulArtichaut
2020-05-22 18:30:26 +02:00
parent a9ca1ec928
commit 01630b26dd
3 changed files with 11 additions and 7 deletions

View File

@@ -86,11 +86,13 @@ pub struct Command {
stderr: Option<Stdio>,
}
// Create a new type for argv, so that we can make it `Send`
// Create a new type for argv, so that we can make it `Send` and `Sync`
struct Argv(Vec<*const c_char>);
// It is safe to make Argv Send, because it contains pointers to memory owned by `Command.args`
// It is safe to make `Argv` `Send` and `Sync`, because it contains
// pointers to memory owned by `Command.args`
unsafe impl Send for Argv {}
unsafe impl Sync for Argv {}
// passed back to std::process with the pipes connected to the child, if any
// were requested