made read blocking, adnd up to 1024 bytes

request env vars before opeing shell
cleanup
This commit is contained in:
neon443
2025-06-26 11:32:45 +01:00
parent e8ca091d0d
commit d9154458fa
4 changed files with 25 additions and 28 deletions

View File

@@ -83,6 +83,10 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
}
ssh_channel_request_env(channel, "TERM", "xterm-256color")
ssh_channel_request_env(channel, "LANG", "en_US.UTF-8")
ssh_channel_request_env(channel, "LC_ALL", "en_US.UTF-8")
do {
try openShell()
} catch {
@@ -90,9 +94,6 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
setTitle("\(host.username)@\(host.address)")
ssh_channel_request_env(channel, "TERM", "xterm-256color")
ssh_channel_request_env(channel, "LANG", "en_US.UTF-8")
ssh_channel_request_env(channel, "LC_ALL", "en_US.UTF-8")
}
func connect() throws(SSHError) {
@@ -380,8 +381,8 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
return nil
}
var buffer: [CChar] = Array(repeating: 0, count: 16_384)
let nbytes = ssh_channel_read_nonblocking(channel, &buffer, UInt32(buffer.count), 0)
var buffer: [CChar] = Array(repeating: 0, count: 1024)
let nbytes = ssh_channel_read(channel, &buffer, UInt32(buffer.count), 0)
guard nbytes > 0 else { return nil }