Add debug output for wsssh process startup and output reading

parent a6b05ef7
......@@ -195,9 +195,10 @@ def connect_terminal(client_id):
# Start a thread to read output
output_buffer = []
def read_output():
output_buffer.append('Process started, reading output...\r\n')
while proc.poll() is None:
try:
data = proc.stdout.read(1024)
data = proc.stdout.read(1) # Read byte by byte for real-time
if data:
output_buffer.append(data.decode('utf-8', errors='ignore'))
except:
......@@ -209,10 +210,13 @@ def connect_terminal(client_id):
output_buffer.append(data.decode('utf-8', errors='ignore'))
except:
pass
output_buffer.append('\r\nProcess finished.\r\n')
thread = threading.Thread(target=read_output, daemon=True)
thread.start()
if proc.poll() is not None:
output_buffer.append(f'\r\nProcess failed to start, exit code: {proc.returncode}\r\n')
active_terminals[request_id] = {'client_id': client_id, 'username': username, 'proc': proc, 'output_buffer': output_buffer}
return jsonify({'request_id': request_id, 'command': ' '.join(command)})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment