Skip to content

Commit

Permalink
Merge pull request #2 from jhowardmsft/jjh/updateeventnames
Browse files Browse the repository at this point in the history
Simplify event names
  • Loading branch information
John Howard authored Feb 15, 2019
2 parents c240f60 + ab0df58 commit a8bd27f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
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

0 comments on commit a8bd27f

Please sign in to comment.