mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00

* rubocop.yml - add more Cops & alphabetize * RuboCop - Performance/UnfreezeString * RuboCop - Style/SafeNavigation * RuboCop - Performance/StringInclude * RuboCop - Performance/StringIdentifierArgument * RuboCop - Performance/RegexpMatch * RuboCop - Performance/MethodObjectAsBlock * RuboCop - Performance/CollectionLiteralInLoop * RuboCop - Performance/ChainArrayAllocation
27 lines
604 B
Ruby
27 lines
604 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'ffi'
|
|
|
|
module Puma
|
|
module JRubyRestart
|
|
extend FFI::Library
|
|
ffi_lib 'c'
|
|
|
|
attach_function :execlp, [:string, :varargs], :int
|
|
attach_function :chdir, [:string], :int
|
|
attach_function :fork, [], :int
|
|
attach_function :exit, [:int], :void
|
|
attach_function :setsid, [], :int
|
|
|
|
def self.chdir_exec(dir, argv)
|
|
chdir(dir)
|
|
cmd = argv.first
|
|
argv = ([:string] * argv.size).zip(argv)
|
|
argv.flatten!
|
|
argv << :string
|
|
argv << nil
|
|
execlp(cmd, *argv)
|
|
raise SystemCallError.new(FFI.errno)
|
|
end
|
|
end
|
|
end
|