brikis98 / docker-osx-dev

A productive development environment with Docker on OS X
http://www.ybrikman.com/writing/2015/05/19/docker-osx-dev/
MIT License
1.43k stars 106 forks source link

multiple processes: starting / stopping? #160

Open cjerdonek opened 8 years ago

cjerdonek commented 8 years ago

I noticed that when running docker-osx-dev sync:

$ docker-osx-dev sync -c <path1> -s <path2> -s <path3>

it starts two additional child processes with the same command:

$ ps xao pid,ppid,command | grep '[d]ocker-osx-dev sync'
69989 50446 /bin/bash /usr/local/bin/docker-osx-dev sync -c <path1> -s <path2> -s <path3>
70145 69989 /bin/bash /usr/local/bin/docker-osx-dev sync -c <path1> -s <path2> -s <path3>
70146 69989 /bin/bash /usr/local/bin/docker-osx-dev sync -c <path1> -s <path2> -s <path3>

Is it supposed to be doing this?

Also, when I send a SIGINT, SIGTERM, or SIGKILL to the parent process from a different process (e.g. from a different terminal window), docker-osx-dev doesn't terminate its two children:

$ kill -15 69989
$ ps xao pid,ppid,command | grep '[d]ocker-osx-dev sync'
70145     1 /bin/bash /usr/local/bin/docker-osx-dev sync -c <path1> -s <path2> -s <path3>
70146     1 /bin/bash /usr/local/bin/docker-osx-dev sync -c <path1> -s <path2> -s <path3>
brikis98 commented 8 years ago

docker-osx-dev fires up fswatch. It also runs boot2docker for you if it isn't already started. Not sure if those are the two processes you're seeing... If you CTRL+C docker-osx-dev itself (instead of the kill command), do those other two go away?

cjerdonek commented 8 years ago

I meant to add that fswatch is also a descendant / grandchild process (a child of one of the two additional child processes), so I'm seeing four in all. Yes, control-c from the same shell kills them all. If it is running as a background process or for automation purposes, it would be better if terminating the parent via a signal terminates its descendants and not just the parent. Here is a page with information on how to do this in bash. I noticed I had a half-dozen orphaned fswatch processes from this.

brikis98 commented 8 years ago

Agreed, docker-osx-dev should do a better job of managing its child processes.