Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • It doesn't work in practice. Actually command stress -c 16 invokes 16 processes. They are invoked by the parent stress process whose pid we get as you have mentioned. When I kill that pid, then others do not get killed and their ownership goes to its parent process. Commented Mar 31, 2017 at 13:51
  • 1
    Then in that case you need to gather the pids of those 16 childs as well. You didnt state that in your query initially. pstree "$pid" -p -a -l > x; kill -9 $(cut -d, -f2 x | cut -d' ' -f1) Commented Apr 1, 2017 at 16:34
  • Of course, I didn't state that because I was assuming that you knew how stress work. Thanks a lot for your answer. It really solves my original problem. I made some minor changes in your command to avoid any file operation: pstree $pid_stress -p -a -l | cut -d, -f2 | cut -d' ' -f1 | xargs kill -9 Commented Apr 3, 2017 at 13:35
  • Meanwhile, I was trying the following in python: os.setpgrp() # create group before stress invocation ./runme os.killpg(0, signal.SIGKILL) # kill all processes in my group This has worked for me. But I will prefer your way. Commented Apr 3, 2017 at 13:37