# Kernel#caller for non-current thread

**URL:** <https://www.ruby-forum.com/t/kernel-caller-for-non-current-thread/73511>\
**Category:** Ruby\
**Created:** [October 24, 2006, 11:55pm UTC](https://www.ruby-forum.com/t/kernel-caller-for-non-current-thread/73511 "2006-10-24T23:55:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveluscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3bc359/32.png) [@steveluscher](https://www.ruby-forum.com/u/steveluscher)\
**Post date:** [October 24, 2006, 11:55pm UTC](https://www.ruby-forum.com/t/kernel-caller-for-non-current-thread/73511/1 "2006-10-24T23:55:16Z")

</div>

Looks like it can be done in C by: set ruby\_frame to the particular  
th-\>frame, call backtrace(), and set it back. Is there a better way or  
has anybody already done it?

Steve

---

<div class="post-metadata">

**Author:** ![steveluscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3bc359/32.png) [@steveluscher](https://www.ruby-forum.com/u/steveluscher)\
**Post date:** [October 25, 2006, 3:15am UTC](https://www.ruby-forum.com/t/kernel-caller-for-non-current-thread/73511/2 "2006-10-25T03:15:36Z")

</div>

Steven L. wrote:

> Looks like it can be done in C by: set ruby\_frame to the particular  
> th-\>frame, call backtrace(), and set it back. Is there a better way or  
> has anybody already done it?

Hm, is there anything in the implementation of #backtrace that could  
cause another thread to run? Maybe Thread.critical=true is needed…

This would be nice to have, if it works.

---

<div class="post-metadata">

**Author:** ![steveluscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3bc359/32.png) [@steveluscher](https://www.ruby-forum.com/u/steveluscher)\
**Post date:** [October 26, 2006, 2:23am UTC](https://www.ruby-forum.com/t/kernel-caller-for-non-current-thread/73511/3 "2006-10-26T02:23:02Z")

</div>

Joel VanderWerf [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Steven L. wrote:
> 
> > Looks like it can be done in C by: set ruby\_frame to the particular  
> > th-\>frame, call backtrace(), and set it back. Is there a better way or  
> > has anybody already done it?
> 
> Hm, is there anything in the implementation of #backtrace that could  
> cause another thread to run? Maybe Thread.critical=true is needed…
> 
> This would be nice to have, if it works.

Unfortunately my initial scan of the source turned out to be too  
quick. structs that I assumed would be defined in one of the header  
files (struct thread) are actually defined in eval.c. I believe a lot  
was opened up in 1.8.5 for Sandbox, but I haven’t checked it yet.

Steve
