[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC 08/59] controller: Exit after second SIGINT



From: George Dunlap <george.dunlap@xxxxxxxxxx>

Otherwise you have to kill -9 the process.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
 main.go | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/main.go b/main.go
index 04c8467..dbd6276 100644
--- a/main.go
+++ b/main.go
@@ -62,6 +62,8 @@ func (ws *WorkerList) Start(report chan WorkerReport, done 
chan bool) {
 }
 
 func main() {
+       killed := false
+       
        count := 2
        
        report := make(chan WorkerReport)
@@ -92,9 +94,15 @@ func main() {
                        i--;
                        fmt.Println(i, "workers left");
                case <-signals:
-                       fmt.Println("SIGINT receieved, shutting down workers")
-                       for j := range Workers {
-                               Workers[j].w.Shutdown()
+                       if ! killed {
+                               fmt.Println("SIGINT receieved, shutting down 
workers")
+                               for j := range Workers {
+                                       Workers[j].w.Shutdown()
+                               }
+                               killed = true
+                       } else {
+                               fmt.Println("Second SIGINT received, exiting 
without cleaning up")
+                               os.Exit(1)
                        }
                }
        }
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.