Skip to content

Commit

Permalink
main: use signal.NotifyContext to handle signals (peak#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
igungor authored Sep 12, 2022
1 parent d21a491 commit 90b7418
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ For macOS, a [homebrew](https://brew.sh) tap is provided:

### Unofficial Releases (by Community)
[![Packaging status](https://repology.org/badge/tiny-repos/s5cmd.svg)](https://repology.org/project/s5cmd/versions)
> **Warning**
> **Warning**
> These releases are maintained by the community. They might be out of date compared to the official releases.
#### MacPorts
Expand Down
11 changes: 2 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ import (
)

func main() {
ctx, cancel := context.WithCancel(context.Background())

go func() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
<-ch
cancel()
signal.Stop(ch)
}()
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()

if err := command.Main(ctx, os.Args); err != nil {
os.Exit(1)
Expand Down

0 comments on commit 90b7418

Please sign in to comment.