Buffered channel for signal interrupt
This commit is contained in:
parent
1c933691ff
commit
3e62223de3
3 changed files with 3 additions and 3 deletions
|
@ -208,7 +208,7 @@ func (camera *Camera) Close() {
|
||||||
// Stops the "cmd" process running when the user presses Ctrl+C.
|
// Stops the "cmd" process running when the user presses Ctrl+C.
|
||||||
// https://stackoverflow.com/questions/11268943/is-it-possible-to-capture-a-ctrlc-signal-and-run-a-cleanup-function-in-a-defe.
|
// https://stackoverflow.com/questions/11268943/is-it-possible-to-capture-a-ctrlc-signal-and-run-a-cleanup-function-in-a-defe.
|
||||||
func (camera *Camera) cleanup() {
|
func (camera *Camera) cleanup() {
|
||||||
c := make(chan os.Signal)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
go func() {
|
go func() {
|
||||||
<-c
|
<-c
|
||||||
|
|
2
video.go
2
video.go
|
@ -154,7 +154,7 @@ func (video *Video) Close() {
|
||||||
// Stops the "cmd" process running when the user presses Ctrl+C.
|
// Stops the "cmd" process running when the user presses Ctrl+C.
|
||||||
// https://stackoverflow.com/questions/11268943/is-it-possible-to-capture-a-ctrlc-signal-and-run-a-cleanup-function-in-a-defe.
|
// https://stackoverflow.com/questions/11268943/is-it-possible-to-capture-a-ctrlc-signal-and-run-a-cleanup-function-in-a-defe.
|
||||||
func (video *Video) cleanup() {
|
func (video *Video) cleanup() {
|
||||||
c := make(chan os.Signal)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
go func() {
|
go func() {
|
||||||
<-c
|
<-c
|
||||||
|
|
|
@ -290,7 +290,7 @@ func (writer *VideoWriter) Close() {
|
||||||
// Stops the "cmd" process running when the user presses Ctrl+C.
|
// Stops the "cmd" process running when the user presses Ctrl+C.
|
||||||
// https://stackoverflow.com/questions/11268943/is-it-possible-to-capture-a-ctrlc-signal-and-run-a-cleanup-function-in-a-defe.
|
// https://stackoverflow.com/questions/11268943/is-it-possible-to-capture-a-ctrlc-signal-and-run-a-cleanup-function-in-a-defe.
|
||||||
func (writer *VideoWriter) cleanup() {
|
func (writer *VideoWriter) cleanup() {
|
||||||
c := make(chan os.Signal)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
go func() {
|
go func() {
|
||||||
<-c
|
<-c
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue