Skip to content

bug: kill isn't a serial killer #40

@i4ki

Description

@i4ki

When we discussed the kill command we talked about that it should really kill (trying first SIGTERM and if it doesn't die then calling SIGKILL).
The problem is that it's not calling SIGKILL if process doesn't dies:

λ> strace kill 17140
execve("/home/i4k/.gvm/pkgsets/go1.8/global/bin/kill", ["kill", "17140"], [/* 32 vars */]) = 0
arch_prctl(ARCH_SET_FS, 0x511428)       = 0
sched_getaffinity(0, 8192, [0 1 2 3])   = 16
mmap(0xc000000000, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000
...
...
kill(17140, SIGTERM)                    = 0
exit_group(0)                           = ?

The problem is that kill(2) returns 0 (ok) when it sends the signal successfully to the process, but that doesn't guarantees that it will die with SIGTERM...
See code here: https://github.com/c0defellas/enzo/blob/master/cmd/kill/kill_unix.go#L13

The right approach would be verify if process is still alive in the next few milliseconds and if so then send a SIGKILL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions