This handle you are writing to is actually the console process.
q)\p 1234 q)h:hopen 1234 q)h 0i
The most common use for this is when you are using slaves, when the 0 handle can be used to run on the main thread. When running without slaves this will just just be like running the expression normally with one possible difference being that process timeouts may still occur if the -T flag is set.
You can find more information about it here:https://code.kx.com/q/ref/filenumbers/#0-console
I'm really curoius, is there is way to send a message from a slave thread back to the main thread to allow parallel processing that have some side effects?
One possible use case is to generate large amount of data in parallel, and send those data to a remote process for futher processing. With the restrictions on slave thread, I obviously cannot use IPC handles directly in the slaves. Due the total data size generated, OTOH, it is also not possible to collect all data back into the main thread before sending them out. And ideal system should be able to simple generate data in parallel, and stream them out into remote processes.
How do I collect them into main thread without going 'wsfull?
f peach til 1000000
Each invocation to f returns a lot of data (and each invocation takes a relatively long time). So trying to wait for the above line to complete will both consume a lot of time and cause 'wsfull eventually. That's why the intention was to allow f to send out the generated data incrementally -- this allows downstream processes to start ASAP and avoids the unnecessary 'wsfull in the current process.