Using process_create for both input and output

Welcome,

While others such as @Jan will most likely give a more exact and helpful answer, one thing that you did not note and that might be of help is to look at the actual code for SWI-Prolog in the GitHub repository.

Be aware that some of the examples may be old as I recently learned but ask if you are not certain.

Hope this helps.