@@ -50,4 +50,12 @@ static inline int tst_get_free_pids(void (*cleanup_fn)(void))
*/
pid_t tst_getpid(void);
+/*
+ * Direct gettid() syscall. Some glibc versions cache gettid() return value
+ * which can cause confusing issues for example in processes created by
+ * direct clone() syscall (without using the glibc wrapper). Use this function
+ * whenever the current process may be a thread of the main test process.
+ */
+pid_t tst_gettid(void);
+
#endif /* TST_PID_H__ */
@@ -166,3 +166,8 @@ pid_t tst_getpid(void)
{
return syscall(SYS_getpid);
}
+
+pid_t tst_gettid(void)
+{
+ return syscall(SYS_gettid);
+}