[WIP] set process group ID when fork/exec so child processes terminate together#695
[WIP] set process group ID when fork/exec so child processes terminate together#695mars1024 wants to merge 2 commits intocontainernetworking:masterfrom
Conversation
f2e3efb to
62f2c79
Compare
|
@mars1024 can you add the sudo back to travis.yaml and see what happens? |
|
Could you cover this change with a test? |
|
Code looks fine; could I ask that you squash the commits and make the title more like "Set the process group so child processes terminate together"? The current title is focused on the side-effect rather than the actual change. |
…ate together Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
62f2c79 to
a6d08e8
Compare
OK, I'll try ~ |
Sure, after CI pass, I'll update some tests. |
Squash done, thanks ~ |
|
Hmm, something is wrong - I can't run the tests locally either. |
Yes, me too, I'm trying to find more info about the broken CI. |
I checked out your PR and ran |
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
a6d08e8 to
7cf0e0c
Compare
|
I tried, but It seems not work if we set pgid to os.GetPid(), otherwise killing process is different from killing process group, we can not expect os/exec in golang to help us kill process group although process group id is same as process id. So I will change to another implementation based on killing process group later. |
|
/hold |
|
Hi, are you likely to come back to this? |
I'll try but need some time to catch up.. |
|
/close |
Provide a experimental way to fix #687
We let sub process called by invoke.Exec has the process group id same as its parent process id, so when the parent process is killed, all the sub processes will be killed in tree recursively.
Fox example, if we use libcni in CRI to call plugin A, and plugin A call plugin B and C, and plugin B call another plugin D, then the pid/pgid maybe like,
If CRI (pid==100) was killed, processes(A pid==103) with group id == 100 will be killed, and processes(B pid==105 C pid==106) with group id == 103 will be killed, and process D will be killed in the same way recursively.
For the same reason , if CRI try to kill process A, B&C&D will be killed recursively.
Signed-off-by: Bruce Ma brucema19901024@gmail.com