Skip to content

Commit 2679c38

Browse files
committed
Auto merge of #72472 - LeSeulArtichaut:sync-command, r=dtolnay
Implement `Sync` for `process::Command on unix and vxworks Closes #72387. r? @cuviper
2 parents 62da38d + 01630b2 commit 2679c38

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/libstd/process.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2105,8 +2105,8 @@ mod tests {
21052105
}
21062106

21072107
#[test]
2108-
fn test_command_implements_send() {
2109-
fn take_send_type<T: Send>(_: T) {}
2110-
take_send_type(Command::new(""))
2108+
fn test_command_implements_send_sync() {
2109+
fn take_send_sync_type<T: Send + Sync>(_: T) {}
2110+
take_send_sync_type(Command::new(""))
21112111
}
21122112
}

src/libstd/sys/unix/process/process_common.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ pub struct Command {
8686
stderr: Option<Stdio>,
8787
}
8888

89-
// Create a new type for argv, so that we can make it `Send`
89+
// Create a new type for argv, so that we can make it `Send` and `Sync`
9090
struct Argv(Vec<*const c_char>);
9191

92-
// It is safe to make Argv Send, because it contains pointers to memory owned by `Command.args`
92+
// It is safe to make `Argv` `Send` and `Sync`, because it contains
93+
// pointers to memory owned by `Command.args`
9394
unsafe impl Send for Argv {}
95+
unsafe impl Sync for Argv {}
9496

9597
// passed back to std::process with the pipes connected to the child, if any
9698
// were requested

src/libstd/sys/vxworks/process/process_common.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ pub struct Command {
4949
stderr: Option<Stdio>,
5050
}
5151

52-
// Create a new type for argv, so that we can make it `Send`
52+
// Create a new type for `Argv`, so that we can make it `Send` and `Sync`
5353
struct Argv(Vec<*const c_char>);
5454

55-
// It is safe to make Argv Send, because it contains pointers to memory owned by `Command.args`
55+
// It is safe to make `Argv` `Send` and `Sync`, because it contains
56+
// pointers to memory owned by `Command.args`
5657
unsafe impl Send for Argv {}
58+
unsafe impl Sync for Argv {}
5759

5860
// passed back to std::process with the pipes connected to the child, if any
5961
// were requested

0 commit comments

Comments
 (0)