Skip to content

Commit 73ad4f0

Browse files
committed
fix(libsinsp): Force CLONE_FILES for threads with missing flag from driver
Add definitive thread detection in parse_clone_exit_child() using the Linux kernel's absolute thread definition: pid != tid. When a thread is detected but missing the CLONE_FILES flag, force the flag to ensure proper FD table sharing between threads.
1 parent a8fb3d2 commit 73ad4f0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

userspace/libsinsp/parsers.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,17 @@ void sinsp_parser::parse_clone_exit_child(sinsp_evt &evt, sinsp_parser_verdict &
11631163
*/
11641164
int64_t lookup_tid;
11651165

1166+
bool is_actually_new_process = (child_tinfo->m_pid == child_tinfo->m_tid);
11661167
bool is_thread_leader = !(child_tinfo->m_flags & PPM_CL_CLONE_THREAD);
1168+
1169+
if(is_thread_leader && !is_actually_new_process) {
1170+
/* we detected a thread with PPM_CL_CONE_THREAD not set
1171+
Force the flag
1172+
**/
1173+
is_thread_leader = false;
1174+
child_tinfo->m_flags |= PPM_CL_CLONE_THREAD;
1175+
}
1176+
11671177
if(is_thread_leader) {
11681178
/* We need to copy data from the parent */
11691179
lookup_tid = child_tinfo->m_ptid;

0 commit comments

Comments
 (0)