MCPcopy Create free account
hub / github.com/apache/impala / SetThreadName

Method SetThreadName

be/src/kudu/util/thread.cc:281–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279};
280
281void ThreadMgr::SetThreadName(const string& name, int64_t tid) {
282 // On linux we can get the thread names to show up in the debugger by setting
283 // the process name for the LWP. We don't want to do this for the main
284 // thread because that would rename the process, causing tools like killall
285 // to stop working.
286 if (tid == getpid()) {
287 return;
288 }
289
290#if defined(__linux__)
291 // http://0pointer.de/blog/projects/name-your-threads.html
292 // Set the name for the LWP (which gets truncated to 15 characters).
293 // Note that glibc also has a 'pthread_setname_np' api, but it may not be
294 // available everywhere and it's only benefit over using prctl directly is
295 // that it can set the name of threads other than the current thread.
296 int err = prctl(PR_SET_NAME, name.c_str());
297#else
298 int err = pthread_setname_np(name.c_str());
299#endif // defined(__linux__)
300 // We expect EPERM failures in sandboxed processes, just ignore those.
301 if (err < 0 && errno != EPERM) {
302 PLOG(ERROR) << "SetThreadName";
303 }
304}
305
306Status ThreadMgr::StartInstrumentation(const scoped_refptr<MetricEntity>& metrics,
307 WebCallbackRegistry* web) const {

Callers 2

SuperviseThreadMethod · 0.45
SuperviseThreadMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected