feat: add double Ctrl+C hard-kill and split TUI into tui.go

First signal cancels the main context; second releases the terminal
and exits 130, unblocking shutdown when captcha polls or user scripts
ignore context. Also moves the bubbletea models and streamProgress
out of sarin.go into a new tui.go.
This commit is contained in:
2026-04-17 16:03:03 +04:00
parent e62fd33f9c
commit 2eebac68c9
4 changed files with 365 additions and 296 deletions

View File

@@ -15,7 +15,8 @@ import (
func main() {
ctx, cancel := context.WithCancel(context.Background())
go listenForTermination(func() { cancel() })
stopCtrl := sarin.NewStopController(cancel)
go listenForTermination(stopCtrl.Stop)
combinedConfig := config.ReadAllConfigs()
@@ -73,7 +74,7 @@ func main() {
}),
)
srn.Start(ctx)
srn.Start(ctx, stopCtrl)
switch *combinedConfig.Output {
case config.ConfigOutputTypeNone:
@@ -87,9 +88,10 @@ func main() {
}
}
func listenForTermination(do func()) {
sigChan := make(chan os.Signal, 1)
func listenForTermination(stop func()) {
sigChan := make(chan os.Signal, 4)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
<-sigChan
do()
for range sigChan {
stop()
}
}