0

Not much to add this question. I want to add a functionality to my process that identifies "bad handles" and drops them.

UPDATE:I know the "bad handle" might sound like a vague term. Basically anything that would prevent me to communicate with the process through IPC.

1 Answers1

1

Im still unsure what you mean by a "bad handle". If you could post an example of what you mean, it would help a lot.

At any time, you can check a handle or a list of handles against key[.z.W], which returns a list of handles which are considered valid by q

You can implement an async ping test, which will test if the process is currently busy.

q)\q -p 5567
q)\q -p 5568
q)h:hopen each 5566+til 3
q)h
3 4 5i
q){valid::x!count[x]#0b;neg[x]@\:({neg[.z.w]"valid[.z.w]:1b"};`);} h
q)valid
3| 1
4| 1
5| 1
q)neg[h 1]("system";"sleep 10")
q){valid::x!count[x]#0b;neg[x]@\:({neg[.z.w]"valid[.z.w]:1b"};`);} h
q)valid
3| 1
4| 0
5| 1

Also any handles that are dropped remotely trigger the .z.pc function, you can add your own logic into this function.

rmorgan
  • 166
  • 5
  • Capturing closed handles via `.z.pc` would be a better approach than the above ping test since connected processes may not necessarily be kdb processes – terrylynch Mar 14 '19 at 12:31