I'm writing two programs (one client, one server) in C that communicate with each other through a UNIX socket. The idea is that the client sends a command to the server, like ls -l, the server creates a child (fork()) and the child does execlp(...,command,...) and the output from execlp is put in the client's terminal window.
However, as it is right now, the output from the commands I send to the server are written in the server's terminal window, not the client's. Is there a way to grab the output from execlp and send it through a socket with send(..,string,...) to the client?
I would like to stick to using sockets, not pipes (all the similar questions I've found have had answers suggesting pipes).