Can I delete if the handle is valid or not

Hi all

I have a problem will save the connection handle from downstream and then publish event to them with code like this:

{
 { (neg x) y }[; x] each exec handle from handleTable
 }

It work ok, however, if there are some downstream shutdown / killed, the the process will keep throwing ‘type’ error as there are some invalid handle.

Just wonder, how can I detect the invalid handle so that I can delete then in code?

possibly .z.pc

Would you elaborate more about your idea? I’ve take a look of http://code.kx.com/wiki/Reference/dotzdotpc but I don’t have a clue about how to implement that

When there is a connection close request, kdb  invokes .z.pc function and parameter to that is handle that’s getting closed. You can override this function to delete the handle from your memory map.

Something like:

.z.pc:{ delete from `handlemap where handle=x}  

This way you can spot and remove the handle which will be invalid going forward right at the time of close request.

Great, thanks, silly me, I don’t aware the handle will pass in as X