return PID from command function

This commit is contained in:
Daniella / Tove 2024-11-22 13:06:16 +01:00
parent f6faf029cd
commit e55a619862
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -812,13 +812,19 @@ pub fn command(stack: &mut Stack) -> OError {
if args.is_empty() {
return stack.err(ErrorKind::InvalidCall("command".to_owned()));
}
process::Command::new(&args[0])
.args(&args[1..])
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.spawn()
.map_err(|x| stack.error(ErrorKind::IO(x.to_string())))?;
stack.push(
Value::Long(
process::Command::new(&args[0])
.args(&args[1..])
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.spawn()
.map_err(|x| stack.error(ErrorKind::IO(x.to_string())))?
.id() as i64,
)
.spl(),
);
Ok(())
}
@ -1195,7 +1201,7 @@ pub fn register(r: &mut Stack, o: Arc<Frame>) {
("alit-end", alit_end, 1),
("import", import, 0),
("readln", readln, 1),
("command", command, 0),
("command", command, 1),
("command-wait", command_wait, 1),
("str-to-bytes", str_to_bytes, 1),
("bytes-to-str", bytes_to_str, 1),