Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Totktonada opened this issue Mar 15, 2024 · 0 comments
Open
Labels
code health Improve code readability, simplify maintenance and so on

Comments

@Totktonada
Copy link
Member

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.

@Totktonada Totktonada added the code health Improve code readability, simplify maintenance and so on label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Improve code readability, simplify maintenance and so on
Projects
None yet
Development

No branches or pull requests

1 participant