Skip to content

Use popen.signal.SIG* constants instead of os.execute('kill -%s %d') #359

Open
@Totktonada

Description

@Totktonada

function Process.kill_pid(pid, signal, options)
checks('number|string', '?number|string', {quiet = '?boolean'})
-- Signal values are platform-dependent so we can not use ffi here
signal = signal or 15
local exit_code = os.execute('kill -' .. signal .. ' ' .. pid .. ' 2> /dev/null')
if exit_code ~= 0 and not (options and options.quiet) then
error('kill failed: ' .. exit_code)
end
end

Tarantool provides signal name to signal number mapping since the 2.4.1 version. We can use it if available and fallback to os.execute() on older versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code healthImprove code readability, simplify maintenance and so on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions