Skip to content

Commit

Permalink
fix: catch and report errors about tty I/O (zellij-org#882)
Browse files Browse the repository at this point in the history
Quick and dirty bandaid fix to some server crashes which occur to me lately.
The underlying issue seems to be a race condition somewhere when the shell in the pane
exits and the tty file descriptor becomes invalid, but zellij wants to write/read it?

Bug trigger:
- open some panes
- exit the shells in the panes by spamming Ctrl-D

works best when the system only runs on a single CPU, run the following to disable all
cores but one:
echo 0 | sudo tee /sys/devices/system/cpu/cpu*/online
  • Loading branch information
raphCode committed Feb 10, 2022
1 parent 4e1043c commit 55e569e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions zellij-server/src/tab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,12 +787,15 @@ impl Tab {
PaneId::Terminal(active_terminal_id) => {
let active_terminal = self.panes.get(&pane_id).unwrap();
let adjusted_input = active_terminal.adjust_input_to_terminal(input_bytes);
self.os_api
if let Err(e) = self
.os_api
.write_to_tty_stdin(active_terminal_id, &adjusted_input)
.expect("failed to write to terminal");
self.os_api
.tcdrain(active_terminal_id)
.expect("failed to drain terminal");
{
log::error!("failed to write to terminal: {}", e);
}
if let Err(e) = self.os_api.tcdrain(active_terminal_id) {
log::error!("failed to drain terminal: {}", e);
}
}
PaneId::Plugin(pid) => {
for key in parse_keys(&input_bytes) {
Expand Down

0 comments on commit 55e569e

Please sign in to comment.