How do you find the current team ID?

According to the Be Book you can find out if areas are shared by testing if the area’s team is equal to the current team. The area_info header contains the team of the area but how do I find out the current team ID? So far I’ve found an iterator for all areas, and another for all teams, but when I try to find a simple getter for the current team there doesn’t seem to be one there. Passing a 0 to most team functions is a shorthand for the current team but that doesn’t seem to work for the comparison.

Call be_app->Team();

See BApplication::GetAppInfo() method here for more info:

1 Like

Here is a more low level version:


Thanks! One of those should work under Rust’s FFI.


AppMisc.h appears to be private so i guess CurrentTeam() shouldn’t be added to the FFI.

I guess I’d better see about making a Rust header for ApplicationKit.

BApplications are only used in GUI applications, generally. Instead, you should call get_thread_info the same way current_team does in the above code.

1 Like

Thanks! I won’t be writing graphical utilities in Wasmer for a while. Now I see what you mean.

The most portable way is to use the get_thread_info(), which is part of libroot and OS.h. See this code snippet for how I did it previously. Both functions called in this code snippet are now part of the libc crate.

Note that you might have to use MaybeUnit<T> on recent rustc builds, because thread_info contains function pointers.

EDIT: just saw that @waddlesplash gave the same answer. I hope the additional notes help.

1 Like

Yeah my intention sharing that snippet was to show how to do it, since it is only a few lines of code. I should have added more context.

1 Like

Maybe use getpid()

Placeholder code banished and real code written.

It’s already written in Rust now.

You were right. It needed the MaybeUninit::<thread_info>::uninit() and an .as_mut_ptr() on the pass into the function. Once the B_OK code was confirmed I assigned it to the .assume_init() quantity.