Skip to content

Graceful shutdown of application impossible with pterm imported #509

@DiceWithSpades

Description

@DiceWithSpades

Hi. I found an issue with using os.Notify along with pterm.

This code will wait 10 seconds after receiving Ctrl+C

package main

import (
	"os"
	"os/signal"
	"syscall"
	"time"
)

func main() {
	sig := make(chan os.Signal)
	signal.Notify(sig, os.Interrupt, syscall.SIGTERM)

	<-sig
	<-time.After(time.Second * 10)
}

but after just adding an import with pterm it will close immediately

package main

import (
	"os"
	"os/signal"
	"syscall"
	"time"

	_ "github.com/pterm/pterm"
)

func main() {
	sig := make(chan os.Signal)
	signal.Notify(sig, os.Interrupt, syscall.SIGTERM)

	<-sig
	<-time.After(time.Second * 10)
}

My environment:

  • pterm version: v0.12.61
  • go version: v1.20.4
  • os: Ubuntu 23.04

Problem is probably related to

pterm/pterm.go

Line 42 in 4b7a4ed

os.Exit(0)

Metadata

Metadata

Assignees

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