-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: John Howard <jhoward@microsoft.com>
- Loading branch information
John Howard
committed
Jul 7, 2015
0 parents
commit 12f7773
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Microsoft | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
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 | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
const EVENT_MODIFY_STATUS = 0x0002 | ||
|
||
var ( | ||
modkernel32 = syscall.NewLazyDLL("kernel32.dll") | ||
procOpenEvent = modkernel32.NewProc("OpenEventW") | ||
procPulseEvent = modkernel32.NewProc("PulseEvent") | ||
) | ||
|
||
func OpenEvent(desiredAccess uint32, inheritHandle bool, name string) (handle syscall.Handle, err error) { | ||
namep, _ := syscall.UTF16PtrFromString(name) | ||
var _p2 uint32 = 0 | ||
if inheritHandle { | ||
_p2 = 1 | ||
} | ||
r0, _, e1 := procOpenEvent.Call(uintptr(desiredAccess), uintptr(_p2), uintptr(unsafe.Pointer(namep))) | ||
use(unsafe.Pointer(namep)) | ||
handle = syscall.Handle(r0) | ||
if handle == syscall.InvalidHandle { | ||
err = e1 | ||
} | ||
return | ||
} | ||
|
||
func PulseEvent(handle syscall.Handle) (err error) { | ||
r0, _, _ := procPulseEvent.Call(uintptr(handle)) | ||
if r0 != 0 { | ||
err = syscall.Errno(r0) | ||
} | ||
return | ||
} | ||
|
||
func main() { | ||
var pid int | ||
flag.IntVar(&pid, "pid", -1, "PID of docker daemon to signal to dump stacks") | ||
flag.Parse() | ||
if pid == -1 { | ||
fmt.Println("Error: pid must be supplied") | ||
return | ||
} | ||
ev := "Global\\docker-daemon-" + 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) | ||
return | ||
} | ||
PulseEvent(h2) | ||
fmt.Println("Daemon signalled successfully. Examine its output for stacks") | ||
} | ||
|
||
var temp unsafe.Pointer | ||
|
||
func use(p unsafe.Pointer) { | ||
temp = p | ||
} |