Skip to content

Commit

Permalink
Name forked tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
saagarjha committed May 27, 2020
1 parent c68e5ec commit a7ba808
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 1 addition & 5 deletions kernel/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,7 @@ int __do_execve(const char *file, struct exec_args argv, struct exec_args envp)
char threadname[16];
strncpy(threadname, current->comm, sizeof(threadname)-1);
threadname[15] = '\0';
#if __APPLE__
pthread_setname_np(threadname);
#else
pthread_setname_np(pthread_self(), threadname);
#endif
set_thread_name(threadname);

// cloexec
// consider putting this in fd.c?
Expand Down
1 change: 1 addition & 0 deletions kernel/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void (*task_run_hook)(void) = NULL;

static void *task_run(void *task) {
current = task;
set_thread_name(current->comm);
if (task_run_hook)
task_run_hook();
else
Expand Down
6 changes: 6 additions & 0 deletions util/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,10 @@ static inline void sigunwind_end() {
should_unwind = false;
}

#if __APPLE__
#define set_thread_name(threadname) pthread_setname_np(threadname)
#else
#define set_thread_name(threadname) pthread_setname_np(pthread_self(), threadname)
#endif

#endif

0 comments on commit a7ba808

Please sign in to comment.