orlandos-nl / Citadel

SSH Client & Server in Swift
MIT License
224 stars 36 forks source link

TTY executing function may stuck forever when inShell is true #49

Closed owenzhao closed 8 months ago

owenzhao commented 11 months ago
截屏2023-10-20 23 46 52

TTY added ";exit\n" in its code. However, if a command has already ended with ";", a parse error of ";;" is risen and the in shell can't quit.

Since the in shell is not quit, the app calls this api won't get the buffer and the app waits forever.

related function:

public func executeCommand(_ command: String, maxResponseSize: Int = .max, mergeStreams: Bool = false, inShell: Bool = false) async throws -> ByteBuffer

Try: "ls abc;" as command.

Joannis commented 10 months ago

I'm not sure what a correct solution would be. After some thought the only idea I have is to set a timeout for executing commands in the shell

owenzhao commented 10 months ago

How about "\\\n;exit\n"? I worked in zsh with "ls abc" with or without ";" at the end.

截屏2023-11-20 03 01 41
Joannis commented 10 months ago

That's a good solution :)