this works:
(defun gettid (thread) (let (z (w (sb-thread::make-semaphore))) (sb-thread:interrupt-thread thread (lambda () (setq z (with-open-file (s "/proc/thread-self/stat") (read s))) (sb-thread:signal-semaphore w))) (sb-thread:wait-on-semaphore w) z))
(mapcar (lambda (x) (cons (gettid x) (sb-thread:thread-name x))) (sb-thread:list-all-threads))
or instead of reading from /proc, use syscall:
(sb-alien:with-alien ((fn (function sb-alien:int sb-alien:int) :extern "syscall")) (let ((a (sb-alien:alien-funcall fn 224))) (if (minusp a) (sb-alien:alien-funcall fn 186) a))))))
this might be ok for development but not sure about production. how dangerous is interrupt-thread used like this?
this works:
(defun gettid (thread) :make-semaphore ))) thread: interrupt- thread
( with-open- file (s "/proc/ thread- self/stat" )
(read s)))
(sb-thread: signal- semaphore w))) thread: wait-on- semaphore w)
(let (z
(w (sb-thread:
(sb-
thread
(lambda ()
(setq z
(sb-
z))
(mapcar (lambda (x) (cons (gettid x) (sb-thread: thread- name x)))
(sb-thread: list-all- threads) )
or instead of reading from /proc, use syscall:
(let ((a (sb-alien:
this might be ok for development but not sure about production.
how dangerous is interrupt-thread used like this?