Skip to content

Commit a8bd27f

Browse files
author
John Howard
authored
Merge pull request #2 from jhowardmsft/jjh/updateeventnames
Simplify event names
2 parents c240f60 + ab0df58 commit a8bd27f

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

Diff for: docker-signal.exe

-76 KB
Binary file not shown.

Diff for: docker-signal.go

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package main
22

3-
// Very simple utility which signals an event. Used to signal a docker
4-
// daemon on Windows to dump its stacks. Usage docker-signal --pid=daemonpid
3+
// Very simple utility which signals an event. Used to signal a process
4+
// on on Windows to either dump its stacks or it's debugger event.
5+
// Works across dockerd.exe; containerd.exe; containerd-shim-runhcs-v1.exe
6+
// Flags: -pid=daemonpid [-debugger]
7+
8+
// go build -o signal-event.exe
59

610
import (
711
"flag"
@@ -42,23 +46,30 @@ func PulseEvent(handle syscall.Handle) (err error) {
4246
}
4347

4448
func main() {
45-
var pid int
46-
var key string
47-
flag.StringVar(&key, "key", "docker-daemon", "The 'key' override in 'Global\\key-pid'. docker=docker-daemon, containerd=containerd-daemon, conatinerd-runhcs-shim-v1=containerd-shim-runhcs-v1")
48-
flag.IntVar(&pid, "pid", -1, "PID of process to signal to dump stacks")
49+
var (
50+
pid int
51+
debugger bool
52+
)
53+
flag.BoolVar(&debugger, "debugger", false, "Signal a debugger event rather than stackdump.")
54+
flag.IntVar(&pid, "pid", -1, "PID of process to signal")
4955
flag.Parse()
5056
if pid == -1 {
5157
fmt.Println("Error: pid must be supplied")
5258
return
5359
}
60+
key := "stackdump"
61+
if debugger {
62+
key = "debugger"
63+
}
64+
5465
ev := fmt.Sprintf("Global\\%s-%s", key, fmt.Sprint(pid))
5566
h2, _ := OpenEvent(EVENT_MODIFY_STATUS, false, ev)
5667
if h2 == 0 {
57-
fmt.Printf("Could not open event. Check PID %d is correct and the daemon is running.\n", pid)
68+
fmt.Printf("Could not open event. Check PID %d is correct and is running.\n", pid)
5869
return
5970
}
6071
PulseEvent(h2)
61-
fmt.Println("Daemon signalled successfully. Examine its output for stacks")
72+
fmt.Println("Signalled successfully.")
6273
}
6374

6475
var temp unsafe.Pointer

0 commit comments

Comments
 (0)