You must write code to transfer data from the socket to master pty and vice versa. This is usually the task of the parent process. Please note that data transfer must be bidirectional. There are many options: a select () loop that tracks both masterfd and socketfd
(just like a hint, very bad code, not for production !!! There is no error and eof check !!!)
for (;;) { FD_ZERO(&set); FD_SET(masterfd,&set); FD_SET(socketfd,&set); select(...,&set,...); if (FD_ISSET(masterfd,&set)) { read(masterfd,&c,1); write(socketfd,&c,1); } if (FD_ISSET(sockerfd,&set)) { read(sochetfd,&c,1); write(masterfd,&c,1); }
or a couple of threads, one for socketfd-> masterfd and one for transfers masterfd-> sockefd.
(just like a hint, very bad code, not for production !!!)
/*thread 1 */ while (read(masterfd,&c,1) > 0) write(socketfd,&c,1); /*thread 2 */ while (read(socketfd,&c,1) > 0) write(masterfdfd,&c,1);
In any case, you should add the code to the parent side of the branch.
Hi
--- EDIT --- Of course, you should not redirect fd 0,1 and 2 to socketfd in the child process.