You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using glog on macOS and noticed that gettid(2) is used to obtain a "thread ID". However, on macOS this function is quite different from Linux and the output is not very useful for logging as it represents the uid and gid of a thread (see the explanation at http://elliotth.blogspot.co.uk/2012/04/gettid-on-mac-os.html, for example). As a result, multiple runs of the same program will usually end up with the same "thread ID" which makes analyzing logs quite painful. The linked blog post also mentions that it's possible to use pthread_threadid_np(3) starting from 10.5. Did you ever consider using this?
The text was updated successfully, but these errors were encountered:
Another reason to switch: on OSX 10.12, using syscall results in a deprecation warning.
/Users/pwnall/workspace/glog/src/utilities.cc:254:17: warning: 'syscall' is deprecated: first deprecated in
macOS 10.12 - syscall(2) is unsupported; please switch to a supported interface. For SYS_kdebug_trace use
kdebug_signpost(). [-Wdeprecated-declarations]
pid_t tid = syscall(__NR_gettid);
^
/usr/include/unistd.h:733:6: note: 'syscall' has been explicitly marked deprecated here
int syscall(int, ...);
^
1 warning generated.
I'm using glog on macOS and noticed that
gettid(2)
is used to obtain a "thread ID". However, on macOS this function is quite different from Linux and the output is not very useful for logging as it represents the uid and gid of a thread (see the explanation at http://elliotth.blogspot.co.uk/2012/04/gettid-on-mac-os.html, for example). As a result, multiple runs of the same program will usually end up with the same "thread ID" which makes analyzing logs quite painful. The linked blog post also mentions that it's possible to usepthread_threadid_np(3)
starting from 10.5. Did you ever consider using this?The text was updated successfully, but these errors were encountered: