T
Task5mo ago
trim21

how task kill process?

I have a process handle SIGHUP SIGINT SIGKILL SIGTERM and SIGQUIT but they are not trigger, how task kill process in watch mode? it looks like it use differnt strategy to stop process when exit watch mode and in watch mode?
1 Reply
trim21
trim215mo ago
this is my testing program:
package main

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

func main() {
signalChan := make(chan os.Signal, 1)

signal.Notify(
signalChan,
os.Interrupt,
os.Kill,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGQUIT,
syscall.SIGKILL,
syscall.SIGTERM,
)

<-signalChan
fmt.Println("shutting down...")
}
package main

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

func main() {
signalChan := make(chan os.Signal, 1)

signal.Notify(
signalChan,
os.Interrupt,
os.Kill,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGQUIT,
syscall.SIGKILL,
syscall.SIGTERM,
)

<-signalChan
fmt.Println("shutting down...")
}
taskfile:
build:test:
sources:
- '**/*.go'
- 'go.sum'
- 'go.mod'
generates:
- tmp/a.exe
cmd: go build -o tmp/a.exe

test:
deps: [ build:test ]
cmds:
- cp tmp/a.exe tmp/test.exe
- tmp/test.exe
build:test:
sources:
- '**/*.go'
- 'go.sum'
- 'go.mod'
generates:
- tmp/a.exe
cmd: go build -o tmp/a.exe

test:
deps: [ build:test ]
cmds:
- cp tmp/a.exe tmp/test.exe
- tmp/test.exe
running on win32
Want results from more Discord servers?
Add your server