@@ -78,7 +78,7 @@ func NewTaskService(ctx context.Context, publisher shim.Publisher, sd shutdown.S
7878 ep : ep ,
7979 shutdown : sd ,
8080 containers : make (map [string ]* runc.Container ),
81- running : make (map [int ][] containerProcess ),
81+ running : make (map [int ]map [ containerProcess ] struct {} ),
8282 earlyExits : make (map [* map [int ][]runcC.Exit ]struct {}),
8383 }
8484 go s .processExits ()
@@ -113,7 +113,7 @@ type service struct {
113113 containers map [string ]* runc.Container
114114
115115 lifecycleMu sync.Mutex
116- running map [int ][] containerProcess // pid -> running process, guarded by lifecycleMu
116+ running map [int ]map [ containerProcess ] struct {} // pid -> running process, guarded by lifecycleMu
117117 // Subscriptions to exits for PIDs not in s.running. Adding/deleting
118118 // subscriptions and dereferencing the subscription pointers must only be
119119 // done while holding lifecycleMu.
@@ -162,10 +162,13 @@ func (s *service) preStart() (handleStarted func(*runc.Container, process.Proces
162162 s .handleProcessExit (ee , c , p )
163163 }
164164 } else {
165- s .running [pid ] = append (s .running [pid ], containerProcess {
165+ if _ , ok := s .running [pid ]; ! ok {
166+ s .running [pid ] = make (map [containerProcess ]struct {})
167+ }
168+ s .running [pid ][containerProcess {
166169 Container : c ,
167170 Process : p ,
168- })
171+ }] = struct {}{}
169172 s .lifecycleMu .Unlock ()
170173 }
171174 }
@@ -589,7 +592,7 @@ func (s *service) processExits() {
589592 if cps , ok := s .running [e .Pid ]; ok {
590593 delete (s .running , e .Pid )
591594 s .lifecycleMu .Unlock ()
592- for _ , cp := range cps {
595+ for cp := range cps {
593596 s .handleProcessExit (e , cp .Container , cp .Process )
594597 }
595598 } else {
0 commit comments