Skip to content

Commit

Permalink
fix(PTY): Fix Steam Plugin
Browse files Browse the repository at this point in the history
- Ommit NixOS modification for now.
- Add error checking to pty.rs if the command does not exist.
  • Loading branch information
pastaq committed Nov 27, 2024
1 parent 2e0443e commit c708809
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
16 changes: 8 additions & 8 deletions core/systems/launcher/interactive_process.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ var logger := Log.get_logger("InteractiveProcess", Log.LEVEL.INFO)

func _init(command: String, cmd_args: PackedStringArray = []) -> void:
# Hack for steam plugin running steamcmd on NixOS
if command.ends_with("steamcmd.sh"):
cmd = "steam-run"
args = PackedStringArray([command])
args.append_array(cmd_args)
return

cmd = command
args = cmd_args
#if command.ends_with("steamcmd.sh"):
#cmd = "steam-run"
#args = PackedStringArray([command])
#args.append_array(cmd_args)
#return

self.cmd = command
self.args = cmd_args


## Start the interactive process
Expand Down
14 changes: 12 additions & 2 deletions extensions/core/src/system/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,23 @@ impl Pty {
// Spawn a task to run the command
let signals_tx = self.tx.clone();
RUNTIME.spawn(async move {
let mut binding = Command::new(command);
let mut binding = Command::new(command.clone());
let cmd = binding
.args(args)
.stdin(stdin)
.stdout(stdout)
.stderr(stderr);
let child = cmd.spawn().unwrap();
let child = match cmd.spawn() {
Ok(child) => child,
Err(e) => {
log::error!("Failed to spawn child process with command: {command:?} {e:?}");
let signal = Signal::Finished { exit_code: -1 };
if let Err(e) = signals_tx.send(signal) {
log::error!("Error sending exit code: {e:?}");
}
return;
}
};

// Get the PID of the process and emit a started signal
let pid = child.id();
Expand Down

0 comments on commit c708809

Please sign in to comment.