Closed rdbo closed 1 year ago
Hey rdbo, I was wondering if you could add a function to your library that retrieves the main thread ID by using similar way for threads. (You can use the GetThreadTimes function on Windows and the /proc/
Hey rdbo, I was wondering if you could add a function to your library that retrieves the main thread ID by using similar way for threads. (You can use the GetThreadTimes function on Windows and the /proc//task//stat file on Linux to compare the execution time of all threads and determine the main thread by finding the thread with the highest execution time.) It would be really helpful. Thanks!
Sounds interesting, although I would guess the main thread would be the parent of all the other threads, right?
Hey rdbo, I was wondering if you could add a function to your library that retrieves the main thread ID by using similar way for threads. (You can use the GetThreadTimes function on Windows and the /proc//task//stat file on Linux to compare the execution time of all threads and determine the main thread by finding the thread with the highest execution time.) It would be really helpful. Thanks!
Sounds interesting, although I would guess the main thread would be the parent of all the other threads, right?
This would be for Linux at least, I'm not sure how this would play on Windows (I don't think threads are separate processes on Windows, so maybe your method would work)
I understand what you're saying about the main thread being the parent of all other threads on Linux. However, I have used the method I suggested (using the GetThreadTimes function on Windows) before and it worked well to determine the main thread. I'm not as familiar with how it applies to Linux, but it may be worth exploring as an option to find the effective way.
Added process time stamp: 546cb4d9d2b33591c6aaae6e03ab567cccb1f9ce and ef88f8f052f228168f12f325856fe1415b551f7c Issue for thread times moved to #126
Why do this? Because then it would be easy to detect PID collision. After all, two processes can't have the same PID and timestamp, that would not be possible.
On Windows, you can get a process timestamp using
GetProcessTimes
and on Linux you can parse/proc/<pid>/stat
and get the creation time.