On Thu, Oct 11, 2018 at 6:16 PM Jan Kara <mailto:jack@xxxxxxx> wrote: >On Thu 04-10-18 00:25:38, Amir Goldstein wrote: >> In order to identify which thread triggered the event in a >> multi-threaded program, add the FAN_EVENT_INFO_TID flag in fanotify_init >> to opt-in for reporting the event creator's thread id information. >> >> Signed-off-by: nixiaoming <nixiaoming@xxxxxxxxxx> >> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> > >Just one question occurred to me (after discussion with a colleague about >this feature): Ming, why do you actually need to know thread ID and >thread-group ID is not enough? Also note that standard glibc threading >functions are *not* going to be compatible with the ID returned from >fanotify (e.g. it will be different from POSIX thread ID as returned by >pthread_self()). So the feature is somewhat difficult to use from >userspace... (at least you could use gettid() systemcall to get the ID of >current thread but there's not glibc wrapper for it). > When using fanotify to monitor system critical directories or files, the monitor and event trigger are not the same process. The monitoring task wants to know which task triggers the event. If the event is triggered by multiple threads, I hope to know which thread is triggered by the task, can't see the pthread id here, but I can see the tid. Thanks