- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: go-best-practices/signal-trapped
Language: Go
Severity: Info
Category: Best Practices
Using signal.Ignore(syscall.SIGKILL)
or signal.Reset(os.Kill)
to handle the SIGKILL
signal is not considered good practice because the SIGKILL
signal is designed to be uncatchable and unignorable.
In most operating systems, including Unix-based systems, the SIGKILL
signal is a special signal that cannot be caught, ignored, or handled by any process. It is intended as a forceful termination signal that immediately terminates a process without allowing it to perform any cleanup or additional operations.
Therefore, attempting to ignore or reset the SIGKILL
signal using signal.Ignore(syscall.SIGKILL)
or signal.Reset(os.Kill)
will have no effect. The process will still be forcefully terminated when a SIGKILL
signal is sent to it.
It is generally not recommended to handle the SIGKILL
signal programmatically because it defeats the purpose of the signal itself, which is to guarantee the immediate termination of a process if needed.
Handling other signals, such as SIGINT
or SIGTERM
, can be useful to gracefully shut down a process and perform necessary cleanup operations before termination. However, SIGKILL
signals should not be caught or ignored as they are meant to forcefully terminate processes without any chance of intervention.
In conclusion, it is not good coding practice to use signal.Ignore(syscall.SIGKILL)
or signal.Reset(os.Kill)
to handle the SIGKILL
signal, as it is not catchable or ignorable by design.
func main () {
signal.Ignore(os.Signal(signal.SIGKILL))
signal.Ignore(os.Kill)
signal.Reset(os.Kill)
signal.Ignore(syscall.SIGKILL)
signal.Notify(p, syscall.SIGKILL)
signal.Notify(p, os.SIGKILL)
}
func main () {
signal.Notify(p, os.SIGUSR1)
}