Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docker-signal.exe
Binary file not shown.
27 changes: 19 additions & 8 deletions docker-signal.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package main

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

// go build -o signal-event.exe

import (
"flag"
Expand Down Expand Up @@ -42,23 +46,30 @@ func PulseEvent(handle syscall.Handle) (err error) {
}

func main() {
var pid int
var key string
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")
flag.IntVar(&pid, "pid", -1, "PID of process to signal to dump stacks")
var (
pid int
debugger bool
)
flag.BoolVar(&debugger, "debugger", false, "Signal a debugger event rather than stackdump.")
flag.IntVar(&pid, "pid", -1, "PID of process to signal")
flag.Parse()
if pid == -1 {
fmt.Println("Error: pid must be supplied")
return
}
key := "stackdump"
if debugger {
key = "debugger"
}

ev := fmt.Sprintf("Global\\%s-%s", key, fmt.Sprint(pid))
h2, _ := OpenEvent(EVENT_MODIFY_STATUS, false, ev)
if h2 == 0 {
fmt.Printf("Could not open event. Check PID %d is correct and the daemon is running.\n", pid)
fmt.Printf("Could not open event. Check PID %d is correct and is running.\n", pid)
return
}
PulseEvent(h2)
fmt.Println("Daemon signalled successfully. Examine its output for stacks")
fmt.Println("Signalled successfully.")
}

var temp unsafe.Pointer
Expand Down