I have a single-threaded process which is not dying on kill -TERM. The process signal mask does not show that SIGTERM is blocked. I'm executing 'kill' as root. I'm able to kill the process using SIGKILL but this is part of a larger system and I'd like SIGTERM to work.
$ cat /proc/5105/status
Name: task_root.nginx
State: S (sleeping)
Tgid: 5105
Pid: 5105
PPid: 1
TracerPid: 0
Uid: 1000 1000 1000 1000
Gid: 1000 1000 1000 1000
FDSize: 256
Groups: 4 24 27 30 46 109 124 1000
VmPeak: 3304480 kB
VmSize: 3304472 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 249060 kB
VmRSS: 320 kB
VmData: 3228468 kB
VmStk: 1012 kB
VmExe: 3020 kB
VmLib: 30232 kB
VmPTE: 1076 kB
VmSwap: 248288 kB
Threads: 1
SigQ: 0/63014
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000004
SigIgn: 0000000000000000
SigCgt: 2000000181001cef
CapInh: 0000000000000000
CapPrm: 0000000000200000
CapEff: 0000000000200000
CapBnd: ffffffffffffffff
Cpus_allowed: ff
Cpus_allowed_list: 0-7
Mems_allowed: 00000000,00000001
Mems_allowed_list: 0
voluntary_ctxt_switches: 16
nonvoluntary_ctxt_switches: 1
Note the Sig* properties. SigCgt, SigIgn, and SigBlk indicate that SIGTERM is neither caught, ignored, or blocked (bit #15 is unset - counting least significant bit as #1). Since the default disposition for SIGTERM is to terminate the process, I'd expect it to get killed. But that does not happen -
$ sudo kill -TERM 5105
$ cat /proc/5105/status | grep Name
Name: task_root.nginx
The process is blocked in the wait() system call, waiting for termination of a sub-process:
$ sudo cat /proc/5105/stack
[<ffffffff8106bfc4>] do_wait+0x1e4/0x260
[<ffffffff8106d230>] sys_wait4+0xa0/0xf0
[<ffffffff81668d02>] system_call_fastpath+0x16/0x1b
[<ffffffffffffffff>] 0xffffffffffffffff
The process is a single threaded process that was created using clone() with flags SIGCHLD | CLONE_NEWPID | CLONE_NEWNS. The PID 5105 is the top level PID as viewed from the parent (default) PID namespace.
Killing the process with SIGKILL works showing that PID or process tracking is not a problem.
Are you sure SIGTERM is signal 15 on your system? You didn't specify OS or architecture in the question, but it's very likely that you can use "kill -l" to list signals (that's a lowercase letter L, not numeral one). What happens if you strace the process, then kill -TERM it? For example:
strace -Tttf -o strace.out -p 5105 &
kill -TERM 5105
Are the signal masks changing? strace should also show if this is happening.