Files
HackBrowserData/cmd/hack-browser-data/main_others.go
T
Roger c0a03769f1 fix: stop cleanly on Ctrl-C, SIGTERM, and SIGHUP (#668)
A signal killed the process mid-run and left the snapshot's copies of browser files in the temp dir.
The run now stops at its next step, removes them, and ends by the same signal, so the exit status and
calling scripts see what they did before. RFC-012 also keeps the list goldens in cmd.
2026-10-29 15:12:30 +08:00

22 lines
482 B
Go

//go:build !windows
package main
import (
"os"
"os/signal"
"syscall"
"time"
)
func configureDoubleClickMode() {}
// exitBy ends the process by sig itself, as the signal would have, so a calling shell or script sees it was stopped.
func exitBy(sig os.Signal) {
signal.Reset(sig)
if s, ok := sig.(syscall.Signal); ok && syscall.Kill(syscall.Getpid(), s) == nil {
time.Sleep(time.Second) // the signal ends the process first unless it was ignored at start
}
os.Exit(1)
}