Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful shutdown of application impossible with pterm imported #509

Closed
SevenOfSpades opened this issue May 18, 2023 · 1 comment · Fixed by #512
Closed

Graceful shutdown of application impossible with pterm imported #509

SevenOfSpades opened this issue May 18, 2023 · 1 comment · Fixed by #512
Assignees
Labels
bug Something isn't working

Comments

@SevenOfSpades
Copy link

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)

@SevenOfSpades SevenOfSpades added the bug Something isn't working label May 18, 2023
@MarvinJWendt
Copy link
Member

MarvinJWendt commented May 19, 2023

Thanks for reporting this issue!
We will release a fix in the next days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants