This procedure is defined in the server but not documented via ad_proc or proc_doc and may be intended as a private interface.
The procedure is defined as:
proc nsmcp::codexProcessSnapshot {roots reader platform budgetMs machine} {
if {$platform eq ""} {set platform $::tcl_platform(os)}
if {$machine eq ""} {set machine $::tcl_platform(machine)}
set began [clock milliseconds]
set result [dict create source none status unavailable reason unsupported-platform capturedAtMs $began elapsedMs 0 processLimit 8 threadLimit 128 processes {}]
if {$platform ne "Linux"} {return $result}
dict set result source linux-proc
set pending {};set seen {};set processes {};set threadsLeft 128;set partial false
foreach pid [lrange $roots 0 7] {
if {[string is integer -strict $pid] && $pid>0} {lappend pending [list $pid {}]}
}
set reason none
while {[llength $pending]>0 && [llength $processes]<8} {
if {[clock milliseconds]-$began>=$budgetMs} {set partial true;set reason time-budget;break}
lassign [lindex $pending 0] pid parent
set pending [lrange $pending 1 end]
if {[dict exists $seen $pid]} {continue}
dict set seen $pid true
set base /proc/$pid
if {[catch {::nsmcp::codexProcIdentity [{*}$reader read $base/stat]} identity]
|| ($parent ne "" && [dict get $identity parentPid] ne $parent)} {
set partial true;continue
}
set record [dict merge [dict create pid $pid] $identity]
if {![catch {{*}$reader read $base/status} text]} {
if {[regexp -line {^Name:\s*([^\n]+)} $text -> name]} {
dict set record name [string range [string trim $name] 0 63]
}
} else {set partial true}
if {![catch {{*}$reader read $base/io} text]} {
foreach {field key} {read_bytes readBytes write_bytes writeBytes} {
if {[regexp -line [format {^%s:\s*([0-9]+)} $field] $text -> value]} {dict set record $key $value}
}
}
# Follow descendants of the launched process, not unrelated Codex runs.
if {![catch {{*}$reader read $base/task/$pid/children 4096} children]} {
set children [regexp -all -inline {[0-9]+} $children]
if {[llength $children]>8} {set partial true}
foreach child [lrange $children 0 7] {
if {$child>0} {lappend pending [list $child $pid]}
}
}
set tids {}
if {[catch {{*}$reader list $base/task} tids]} {set partial true}
set validTids {}
foreach tid $tids {if {[string is integer -strict $tid] && $tid>0} {lappend validTids $tid}}
set validTids [lsort -integer $validTids]
dict set record threadCount [llength $validTids]
set threads {}
foreach tid $validTids {
if {$threadsLeft<=0 || [clock milliseconds]-$began>=$budgetMs} {set partial true;break}
incr threadsLeft -1
set task $base/task/$tid
if {[catch {::nsmcp::codexProcIdentity [{*}$reader read $task/stat]} state]} {set partial true;continue}
set thread [dict remove [dict merge [dict create tid $tid] $state] parentPid startTicks]
if {![catch {{*}$reader read $task/comm 128} name]} {dict set thread name [string trim $name]}
if {![catch {{*}$reader read $task/wchan 128} value]} {dict set thread waitChannel [string trim $value]}
if {![catch {{*}$reader read $task/syscall 512} value]
&& [regexp {^\s*(-?[0-9]+)\s} $value -> syscall]} {
dict set thread syscall $syscall
# Linux syscall numbers differ by architecture. Retain only
# the descriptor for known reads; never retain buffer addresses.
set operation {}
if {$machine in {x86_64 amd64}} {
switch $syscall {0 {set operation read} 17 {set operation pread64}}
} elseif {$machine in {aarch64 arm64}} {
switch $syscall {63 {set operation read} 67 {set operation pread64}}
}
if {[dict get $thread state] eq "D" && $operation ne ""} {
dict set thread readOperation $operation
dict set thread fileResolution unavailable
if {[regexp {^\s*-?[0-9]+\s+(0x[0-9a-fA-F]+|[0-9]+)\s} $value -> descriptor]
&& ![catch {expr {wide($descriptor)}} fd] && $fd>=0 && $fd<=2147483647} {
dict set thread fileDescriptor $fd
if {[clock milliseconds]-$began<$budgetMs
&& ![catch {{*}$reader readlink $base/fd/$fd} path]
&& [string length $path]<=1024
&& [string index $path 0] eq "/"
&& ![regexp {[\x00-\x1f\x7f]} $path]} {
dict set thread filePath $path
dict set thread fileResolution resolved
}
}
}
}
lappend threads $thread
}
dict set record threads $threads
dict set record omittedThreads [expr {[llength $validTids]-[llength $threads]}]
lappend processes $record
}
if {[llength $pending]>0} {set partial true}
if {$reason eq "none" && $partial} {set reason limited-or-unavailable}
if {[llength $processes]==0 && $reason eq "none"} {set reason no-process}
dict set result status [expr {[llength $processes]==0 ? "unavailable" : ($partial ? "partial" : "complete")}]
dict set result reason $reason
dict set result processes $processes
dict set result elapsedMs [expr {max(0,[clock milliseconds]-$began)}]
return $result
}