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 kvm_openfiles instead of kvm_open for BSD #114

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/bsd/sys/freebsd/sys/proctable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ class Error < StandardError; end
#
def self.ps(**kwargs)
pid = kwargs[:pid]
errbuf = 0.chr * POSIX2_LINE_MAX

begin
kd = kvm_open(nil, nil, nil, 0, nil)
kd = kvm_openfiles(nil, nil, nil, 0, errbuf)

if kd.null?
raise SystemCallError.new('kvm_open', FFI.errno)
error = errbuf.split(0.chr).first
raise SystemCallError.new("kvm_openfiles - #{error}", FFI.errno)
end

ptr = FFI::MemoryPointer.new(:int) # count
Expand Down
1 change: 1 addition & 0 deletions lib/bsd/sys/freebsd/sys/proctable/constants.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Sys
module ProcTableConstants
POSIX_ARG_MAX = 4096
POSIX2_LINE_MAX = 2048

KERN_PROC_PID = 1
KERN_PROC_PROC = 8
Expand Down
2 changes: 1 addition & 1 deletion lib/bsd/sys/freebsd/sys/proctable/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ProcTableFunctions
ffi_lib :kvm

attach_function :devname, [:dev_t, :mode_t], :string
attach_function :kvm_open, [:string, :string, :string, :int, :string], :pointer
attach_function :kvm_openfiles, [:string, :string, :string, :int, :buffer_out], :pointer
attach_function :kvm_close, [:pointer], :int
attach_function :kvm_getprocs, [:pointer, :int, :int, :pointer], :pointer
attach_function :kvm_getargv, [:pointer, :pointer, :int], :pointer
Expand Down
Loading