@@ -112,22 +112,15 @@ proc which_exe {name} {
112112} ;# which_exe
113113
114114proc check_rt_privileges {} {
115- # Without 'sudo make setuid' (or 'sudo make setcap') rtapi_app runs
116- # unprivileged: realtime threads get no SCHED_FIFO and no locked memory, so
117- # the latency readings are wildly inflated. Warn rather than mislead.
118- # Only meaningful on an RT-capable kernel; stay quiet on non-RT (e.g. dev).
119- set rt 0
120- if {![catch {exec uname -v} kv] && [string match *PREEMPT_RT* $kv ]} {set rt 1}
121- if {[string first rtai [string tolower $::tcl_platform(osVersion) ]] >= 0} {set rt 1}
122- if {!$rt } return
123- if {![catch {exec id -u} uid] && $uid == 0} return ;# root has every privilege
124- if {[catch {which_exe rtapi_app} rtapi]} return ;# cannot locate, stay quiet
125- if {![catch {file attributes $rtapi -permissions} mode] && ($mode & 04000)} return ;# setuid root
126- if {![catch {exec getcap $rtapi } caps] && [string match *cap_sys_nice* $caps ]} return ;# file caps
127- set msg " Warning: rtapi_app is not setuid root and has no realtime capabilities."
128- append msg " \n Realtime threads get no SCHED_FIFO priority or locked memory,"
115+ # Ask the realtime layer whether realtime is actually available, via
116+ # 'realtime verify' (exits 0 when realtime is up, non-zero otherwise,
117+ # usually a missing 'sudo make setuid' or 'sudo make setcap').
118+ if {[catch {exec linuxcnc_var REALTIME} rt]} return ;# cannot locate, stay quiet
119+ if {![catch {exec $rt verify 2>@1}]} return ;# realtime available
120+ set msg " Warning: realtime is not available."
121+ append msg " \n Threads get no SCHED_FIFO priority or locked memory,"
129122 append msg " \n so the latency shown will be far worse than reality."
130- append msg " \n Run 'sudo make setuid' (or 'sudo make setcap') in src/."
123+ append msg " \n On a run-in-place build, run 'sudo make setuid' (or 'sudo make setcap') in src/."
131124 puts stderr $msg
132125 if {$::LH(use_x) } {
133126 package require Tk
@@ -649,6 +642,7 @@ proc start_collection {} {
649642 }
650643 }
651644 hal start
645+ check_rt_privileges
652646 if {!$::LH(legacy) } {
653647 # Attach the Tcl hal_stream binding (added in halsh.c) to each
654648 # thread's latencybinstream FIFO. The handle stays open for the
@@ -997,7 +991,6 @@ proc windowToFile { win } {
997991if ![info exists ::LH(start)] {
998992 set_defaults
999993 config
1000- check_rt_privileges
1001994 progress " Loading packages"
1002995 load_packages
1003996 signal trap SIGINT finish
0 commit comments