trace signal
trace signal
Requirements
- Minimum Kernel Version : 5.4
Getting started
Running the gadget:
- kubectl gadget
- ig
$ kubectl gadget run ghcr.io/inspektor-gadget/gadget/trace_signal:v0.55.0 [flags]
$ sudo ig run ghcr.io/inspektor-gadget/gadget/trace_signal:v0.55.0 [flags]
Flags
--failed
Show only failed events
Default value: "false"
--pid
Show only events generated by processes with this pid
Default value: ""
--kill-only
Show only events generated by kill family syscalls
Default value: "false"
--signal
Show only events generated by this signal
Default value: ""
Guide
In this example, we will use the trace_signal gadget to observe signals sent between processes inside a container.
First, we need to run an application.
- kubectl gadget
- ig
$ kubectl run --restart=Never --image=busybox mypod -- sh -c 'while true; do sleep 60 & wait $!; done'
pod/mypod created
$ docker run --name test-signal -d busybox sh -c 'while true; do sleep 60 & wait $!; done'
Then, let's run the gadget:
- kubectl gadget
- ig
$ kubectl gadget run trace_signal:v0.55.0 --podname mypod
K8S.NODE K8S.NAMESPACE K8S.PODNAME K8S.CONTAINE… COMM PID TID TCOMM TPID SIG ERROR
In another terminal, send a signal to the sleeping process:
$ kubectl exec mypod -- sh -c 'kill -SIGTERM $(pgrep sleep)'
Back in the gadget terminal, we can observe the signal being sent:
minikube-docker default mypod mypod sh 522100 522100 sleep 522105 SIGTERM
^C
The COMM and PID columns show the process that sent the signal, while TCOMM and TPID show the target process.
We can stop the gadget by hitting Ctrl-C.
$ sudo ig run trace_signal:v0.55.0 --containername test-signal
RUNTIME.CONTAINERNA… COMM PID TID TCOMM TPID SIG ERROR
In another terminal, send a signal to the sleeping process:
$ docker exec test-signal sh -c 'kill -SIGTERM $(pgrep sleep)'
Back in the gadget terminal, we can observe the signal:
test-signal sh 522100 522100 sleep 522105 SIGTERM
^C
Finally, clean the system:
- kubectl gadget
- ig
$ kubectl delete pod mypod
$ docker rm -f test-signal