Start boosts the process tree.
(tree *processtree.ProcessTree, done chan bool)
| 18 | |
| 19 | // Start boosts the process tree. |
| 20 | func Start(tree *processtree.ProcessTree, done chan bool) chan bool { |
| 21 | quit := make(chan bool) |
| 22 | go func() { |
| 23 | path, _ := filepath.Abs(unixsocket.ZeusSockName()) |
| 24 | os.Remove(path) // Clean up stale socket from previous session |
| 25 | addr, err := net.ResolveUnixAddr("unix", path) |
| 26 | if err != nil { |
| 27 | zerror.Error("Can't open socket.") |
| 28 | } |
| 29 | listener, err := net.ListenUnix("unix", addr) |
| 30 | if err != nil { |
| 31 | zerror.ErrorCantCreateListener() |
| 32 | } |
| 33 | |
| 34 | connections := make(chan *unixsocket.Usock) |
| 35 | go func() { |
| 36 | for { |
| 37 | conn, err := listener.AcceptUnix() |
| 38 | if err != nil { |
| 39 | return // listener was closed |
| 40 | } |
| 41 | connections <- unixsocket.New(conn) |
| 42 | } |
| 43 | }() |
| 44 | |
| 45 | for { |
| 46 | select { |
| 47 | case <-quit: |
| 48 | listener.Close() |
| 49 | done <- true |
| 50 | return |
| 51 | case conn := <-connections: |
| 52 | go handleClientConnection(tree, conn) |
| 53 | } |
| 54 | } |
| 55 | }() |
| 56 | return quit |
| 57 | } |
| 58 | |
| 59 | // see docs/client_master_handshake.md |
| 60 | func handleClientConnection(tree *processtree.ProcessTree, usock *unixsocket.Usock) { |
no test coverage detected
searching dependent graphs…