Hello everyone, I faced with same problem when slave goes offline during the build using SSH or JNLP agent. TLDR: Process hierarchy of Jenkins agent and build shell with same PGID, so kill(pid = 0, signal = SIGTERM) will crash Jenkins agent too.
PID PGID SID TPGID COMMAND
13691 13691 49864 13691 java -jar agent.jar
13818 13691 49864 13691 \_ /bin/sh -xe /tmp/jenkins4748921288996267614.sh
13820 13691 49864 13691 \_ kill(0, SIGTERM)
**I propose some agent demonization for except such bug (call setsid() in thread pool?) Description: For our example we builds many project using make, so it build and abort build many times,GNU make has pid = 0 in internal structure, so when we click abort build on Jenkins it send SIGTERM to child processes -> make send SIGTERM to child and sometimes GNU make (fixed after ) calls `kill(0, SIGTERM)` which means on Linux agent that all the process group will be terminated included Jenkins agent -> so we get died agent during the build. |