浏览文件
stop_notification.go
23 行 · 521 B历史下载| 1 | package limaembed |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | |
| 7 | "github.com/sylvinus/agent-vm/internal/host" |
| 8 | ) |
| 9 | |
| 10 | // One hostagent runs in this process. Buffering preserves cancellation that |
| 11 | // arrives while the driver and hostagent are still initializing. |
| 12 | var hostagentSignals = make(chan os.Signal, 1) |
| 13 | |
| 14 | func notifyHostagentStop() { |
| 15 | select { |
| 16 | case hostagentSignals <- os.Interrupt: |
| 17 | default: |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | func watchHostagentStop(socket string) (func(), error) { |
| 22 | return host.ListenInstanceStop(filepath.Dir(socket), notifyHostagentStop) |
| 23 | } |

