From 01630b26ddcf647a6e87a0d6a18055a7c516cdbc Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Fri, 22 May 2020 18:30:26 +0200 Subject: [PATCH] Implement `Sync` for `process::Command on unix and vxworks --- src/libstd/process.rs | 6 +++--- src/libstd/sys/unix/process/process_common.rs | 6 ++++-- src/libstd/sys/vxworks/process/process_common.rs | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index f7e7a5abf8ea6..4ba1940fd0ece 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -2105,8 +2105,8 @@ mod tests { } #[test] - fn test_command_implements_send() { - fn take_send_type(_: T) {} - take_send_type(Command::new("")) + fn test_command_implements_send_sync() { + fn take_send_sync_type(_: T) {} + take_send_sync_type(Command::new("")) } } diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 859da691ad278..2d7267263dedf 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -86,11 +86,13 @@ pub struct Command { stderr: Option, } -// 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 diff --git a/src/libstd/sys/vxworks/process/process_common.rs b/src/libstd/sys/vxworks/process/process_common.rs index 6d5506bec5f7d..78b6e9a4db785 100644 --- a/src/libstd/sys/vxworks/process/process_common.rs +++ b/src/libstd/sys/vxworks/process/process_common.rs @@ -49,11 +49,13 @@ pub struct Command { stderr: Option, } -// 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