That is what the shell script is for: managing the lifetime of said processes, and storing any globals you might need.
The real issu with this approach in my opinion is that a stream of bytes is just too generic, and the necessary (de)serialization is going to eat a lot of CPU for not useful task
The real issu with this approach in my opinion is that a stream of bytes is just too generic, and the necessary (de)serialization is going to eat a lot of CPU for not useful task