-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used procfs to give traced threads more helpful names
Signed-off-by: Aaron Lamoreaux <[email protected]>
- Loading branch information
Showing
5 changed files
with
88 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
open! Core | ||
open! Import | ||
|
||
module Entry = struct | ||
module Cmdline = struct | ||
type t = string list | ||
end | ||
end | ||
|
||
let state = Hashtbl.create (module Pid) | ||
|
||
let read_proc_info pid = | ||
let line = In_channel.read_lines [%string "/proc/%{pid#Pid}/cmdline"] |> List.hd in | ||
match line with | ||
| None -> () | ||
| Some args -> | ||
let cmdline = | ||
String.split ~on:(Char.of_int_exn 0) args |> List.filter ~f:(Fn.non String.is_empty) | ||
in | ||
Hashtbl.set state ~key:pid ~data:cmdline | ||
;; | ||
|
||
let read_all_proc_info () = | ||
Sys_unix.readdir "/proc" | ||
|> Array.iter ~f:(fun filename -> | ||
try Pid.of_string filename |> read_proc_info with | ||
| _ -> ()) | ||
;; | ||
|
||
let cmdline_of_pid pid = Hashtbl.find state pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
open! Core | ||
open! Import | ||
|
||
module Entry : sig | ||
module Cmdline : sig | ||
type t = string list | ||
end | ||
end | ||
|
||
val read_proc_info : Pid.t -> unit | ||
val read_all_proc_info : unit -> unit | ||
val cmdline_of_pid : Pid.t -> Entry.Cmdline.t option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters