* Added function team_init_exit_info_on_error() which initializes the team's

exit info with some generic status.
* team_create_thread_start(), common_thread_entry(): Initializes the team's
  exit info (if that's the main thread) before calling thread_exit(). Fixes
  #7686.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42183 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2011-06-14 13:04:31 +00:00
parent dc2b8faba2
commit 9437559db1
3 changed files with 27 additions and 0 deletions
+1
View File
@@ -36,6 +36,7 @@ char **user_team_get_arguments(void);
int user_team_get_arg_count(void);
struct job_control_entry* team_get_death_entry(Team *team,
thread_id child, bool* _deleteEntry);
void team_init_exit_info_on_error(Team* team);
bool team_is_valid(team_id id);
Team *team_get_team_struct_locked(team_id id);
int32 team_max_teams(void);
+22
View File
@@ -1577,6 +1577,7 @@ static status_t
team_create_thread_start(void* args)
{
team_create_thread_start_internal(args);
team_init_exit_info_on_error(thread_get_current_thread()->team);
thread_exit();
// does not return
return B_OK;
@@ -3243,6 +3244,27 @@ team_set_job_control_state(Team* team, job_control_state newState,
}
/*! Inits the given team's exit information, if not yet initialized, to some
generic "killed" status.
The caller must not hold the team's lock. Interrupts must be enabled.
\param team The team whose exit info shall be initialized.
*/
void
team_init_exit_info_on_error(Team* team)
{
TeamLocker teamLocker(team);
if (!team->exit.initialized) {
team->exit.reason = CLD_KILLED;
team->exit.signal = SIGKILL;
team->exit.signaling_user = geteuid();
team->exit.status = 0;
team->exit.initialized = true;
}
}
/*! Adds a hook to the team that is called as soon as this team goes away.
This call might get public in the future.
*/
+4
View File
@@ -721,6 +721,10 @@ common_thread_entry(void* _args)
if (args->enterUserland) {
enter_userspace(thread, (UserThreadEntryArguments*)args);
// only returns or error
// If that's the team's main thread, init the team exit info.
if (thread == thread->team->main_thread)
team_init_exit_info_on_error(thread->team);
}
// we're done