Clean up exec fifos on process exit
| ... | ... |
@@ -36,6 +36,19 @@ func (ctr *container) clean() error {
|
| 36 | 36 |
return nil |
| 37 | 37 |
} |
| 38 | 38 |
|
| 39 |
+// cleanProcess removes the fifos used by an additional process. |
|
| 40 |
+// Caller needs to lock container ID before calling this method. |
|
| 41 |
+func (ctr *container) cleanProcess(id string) {
|
|
| 42 |
+ if p, ok := ctr.processes[id]; ok {
|
|
| 43 |
+ for _, i := range []int{syscall.Stdin, syscall.Stdout, syscall.Stderr} {
|
|
| 44 |
+ if err := os.Remove(p.fifo(i)); err != nil {
|
|
| 45 |
+ logrus.Warnf("failed to remove %v for process %v: %v", p.fifo(i), id, err)
|
|
| 46 |
+ } |
|
| 47 |
+ } |
|
| 48 |
+ } |
|
| 49 |
+ delete(ctr.processes, id) |
|
| 50 |
+} |
|
| 51 |
+ |
|
| 39 | 52 |
func (ctr *container) spec() (*specs.Spec, error) {
|
| 40 | 53 |
var spec specs.Spec |
| 41 | 54 |
dt, err := ioutil.ReadFile(filepath.Join(ctr.dir, configFilename)) |
| ... | ... |
@@ -145,11 +158,14 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
|
| 145 | 145 |
|
| 146 | 146 |
// Remove process from list if we have exited |
| 147 | 147 |
// We need to do so here in case the Message Handler decides to restart it. |
| 148 |
- if st.State == StateExit {
|
|
| 148 |
+ switch st.State {
|
|
| 149 |
+ case StateExit: |
|
| 149 | 150 |
if os.Getenv("LIBCONTAINERD_NOCLEAN") != "1" {
|
| 150 | 151 |
ctr.clean() |
| 151 | 152 |
} |
| 152 | 153 |
ctr.client.deleteContainer(e.Id) |
| 154 |
+ case StateExitProcess: |
|
| 155 |
+ ctr.cleanProcess(st.ProcessID) |
|
| 153 | 156 |
} |
| 154 | 157 |
ctr.client.q.append(e.Id, func() {
|
| 155 | 158 |
if err := ctr.client.backend.StateChanged(e.Id, st); err != nil {
|