Go Blocking the Main Thread until Ctrl-C is Entered

From NovaOrdis Knowledge Base
Revision as of 23:26, 14 December 2023 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

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

func waitForCtrlC() {
  c := make(chan os.Signal, 1)
  signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
  <-c
}