Skip to content

Commit 12c59da

Browse files
committed
Add Popen cwd support
1 parent 608572b commit 12c59da

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

vm/src/stdlib/subprocess.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::cell::RefCell;
2+
use std::ffi::OsString;
23
use std::fs::File;
34
use std::time::Duration;
45

@@ -38,6 +39,8 @@ struct PopenArgs {
3839
stdout: Option<i64>,
3940
#[pyarg(positional_or_keyword, default = "None")]
4041
stderr: Option<i64>,
42+
#[pyarg(positional_or_keyword, default = "None")]
43+
cwd: Option<PyStringRef>,
4144
}
4245

4346
impl IntoPyObject for subprocess::ExitStatus {
@@ -96,13 +99,15 @@ impl PopenRef {
9699
.map(|x| objstr::get_value(x))
97100
.collect(),
98101
};
102+
let cwd = args.cwd.map(|x| OsString::from(x.as_str()));
99103

100104
let process = subprocess::Popen::create(
101105
&command_list,
102106
subprocess::PopenConfig {
103107
stdin,
104108
stdout,
105109
stderr,
110+
cwd,
106111
..Default::default()
107112
},
108113
)

0 commit comments

Comments
 (0)