Skip to content

Commit

Permalink
tui: don't log.Fatal on appView.Run error
Browse files Browse the repository at this point in the history
When the user closes their terminal (as opposed to ctrl-c), the terminal
might close the tty without waiting for process-compose to exit. This
causes pcv.appView.Run to return an error, which triggers a log.Fatal:

  ERR Failed to start TUI error="read /dev/tty: input/output error"

This leads to a race where log.Fatal might call os.Exit before the
project's processes can be stopped, leaving them orphaned.

Change log.Fatal to log.Error and explicitly shutdown the project to
make sure processes aren't left behind.
  • Loading branch information
gcurtis authored and F1bonacc1 committed Sep 18, 2024
1 parent 2b65c79 commit c3f3293
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,17 @@ func RunTUIAsync(project app.IProject, options ...Option) {
setupTui(project, options...)
go func() {
if err := pcv.appView.Run(); err != nil {
log.Fatal().Err(err).Msgf("Failed to start TUI")
log.Error().Err(err).Msgf("TUI stopped")
pcv.handleShutDown()
}
}()
}

func RunTUI(project app.IProject, options ...Option) {
setupTui(project, options...)
if err := pcv.appView.Run(); err != nil {
log.Fatal().Err(err).Msgf("Failed to start TUI")
log.Error().Err(err).Msgf("TUI stopped")
pcv.handleShutDown()
}
}

Expand Down

0 comments on commit c3f3293

Please sign in to comment.