On Thu, 11 Nov 2021 21:02:34 +0900 Takashi Yano wrote: > On Thu, 11 Nov 2021 12:33:21 +0100 > Corinna Vinschen wrote: > > On Nov 11 20:12, Takashi Yano wrote: > > > > [FileProcessIdsUsingFileInformation] > > > > > > Thanks for advice. get_query_hdl_per_* is called in the write side, > > > so only knows pipe handle of the write side. We would like to know > > > ProcessId which have pipe handle of the read side. Can we use > > > FileProcessIdsUsingFileInformation for this perpose? > > > > I don't know. I just stumbled over it yesterday and I thought it might > > be something we could utilize. Supposedly it returns PIDs for processes > > having that file open, but how this works for pipe read/write sides > > needs testing. Of course, knowing how Windows functions usually only go > > half the way, the function will either only return the current side of > > the pipe, or even an error code :-/ Never mind, it was just an idea. > > I have tested the behaviour of FileProcessIdsUsingFileInformation > just now. We can use it! I will try to use it in get_query_hdl(). I have tried to utilize FileProcessIdsUsingFileInformation in get_query_hdl_per_process() as the patch attached. It works as expected. I also measured the response of select() using these functions. The first time and second time responses are measured. The second time should be much faster than the first time because search result has been cached. First time, Second time 4.620400 [msec], 0.102300 [msec] << get_query_hdl_per_process() 19.080400 [msec], 0.199000 [msec] << get_query_hdl_per_system() 14.364300 [msec], 0.156800 [msec] << FileProcessIdsUsingFileInformation Unfortunately, FileProcessIdsUsingFileInformation is slower than current get_query_hdl_per_process(). It takes about 3 times longer time. -- Takashi Yano