Bug: suspendProcess() missing signal.Stop causes signal channel leak
In tty_unix.go, the suspendProcess() function registers a channel with signal.Notify to listen for SIGCONT but never calls signal.Stop after the signal is received.
According to Go docs for signal.Notify, callers should use signal.Stop to deregister the channel.
Impact
Each time the user presses Ctrl+Z to suspend the program, a new buffered channel is registered via signal.Notify(c, syscall.SIGCONT) and never deregistered:
- Signal channel leak: Every suspend/resume cycle leaves one more registered-but-abandoned channel
- Memory leak: Each leaked channel occupies memory until program termination
- Future SIGCONT signals attempt delivery to all abandoned channels
Contrast with Correct Usage
handleSignals() in tea.go correctly uses: defer signal.Stop(sig)
listenForResize() in signals_unix.go correctly uses: defer signal.Stop(sig)
But suspendProcess() in tty_unix.go is missing this call.
Fix
Add defer signal.Stop(c) in suspendProcess():
func suspendProcess() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGCONT)
defer signal.Stop(c)
_ = syscall.Kill(0, syscall.SIGTSTP)
<-c
}
Bug: suspendProcess() missing signal.Stop causes signal channel leak
In tty_unix.go, the suspendProcess() function registers a channel with signal.Notify to listen for SIGCONT but never calls signal.Stop after the signal is received.
According to Go docs for signal.Notify, callers should use signal.Stop to deregister the channel.
Impact
Each time the user presses Ctrl+Z to suspend the program, a new buffered channel is registered via signal.Notify(c, syscall.SIGCONT) and never deregistered:
Contrast with Correct Usage
handleSignals() in tea.go correctly uses: defer signal.Stop(sig)
listenForResize() in signals_unix.go correctly uses: defer signal.Stop(sig)
But suspendProcess() in tty_unix.go is missing this call.
Fix
Add defer signal.Stop(c) in suspendProcess():