Skip to content

Importing pterm causes program to not exit on SIGINT and SIGTERM #562

@adombeck

Description

@adombeck

The signal handlers for os.Interrupt and syscall.SIGTERM registered in the init function prevent Go's default behavior when receiving such a signal (exiting with an exit code which depends on the OS and/or signal):

pterm/pterm.go

Lines 31 to 43 in e376aa8

func init() {
color.ForceColor()
// Make the cursor visible when the program stops
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
go func() {
for range c {
cursor.Show()
}
}()
}

In effect, any program which merely imports pterm does not exit when handling a SIGINT (e.g. by pressing Ctrl+C) or a SIGTERM (e.g. by calling kill $PID).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions