air icon indicating copy to clipboard operation
air copied to clipboard

The `sh` process will be a zombie when the command was finished by itself.

Open makiuchi-d opened this issue 3 years ago • 0 comments

Run this program by air:

package main

import (
	"time"
)

func main() {
	time.Sleep(10 * time.Second)
}

air execute the sh as a sub process wrapping the target program main:

$ pstree -p 82908
bash(82908)───air(114873)─┬─sh(114942)───main(114943)─┬─{main}(114944)
                          │                           ├─{main}(114945)
                          │                           ├─{main}(114946)
                          │                           └─{main}(114947)
                          ├─{air}(114874)
                          ├─{air}(114875)
                          ├─{air}(114876)
                          ├─{air}(114877)
                          ├─{air}(114878)
                          ├─{air}(114879)
                          └─{air}(114880)
$ ps 114942
    PID TTY      STAT   TIME COMMAND
 114942 pts/5    Ss+    0:00 /bin/sh -c /home/makki/Projects/test/airzombie/tmp/main

Ten seconds later, the main had finished and sh has been a zombie:

$ ps 114942
    PID TTY      STAT   TIME COMMAND
 114942 ?        Zs     0:00 [sh] <defunct>

The reason is that it does not wait the sh process until the fsnotify event occurs.

makiuchi-d avatar Apr 12 '21 08:04 makiuchi-d