How to use pseudo-terminals in Linux with C?

后端 未结 3 2034
青春惊慌失措
青春惊慌失措 2020-12-03 17:42

I\'m trying to figure out how to use pseudo-terminal\'s in linux, essentially I want to create a telnetd clone, something I mentioned in an earlier question.

I under

3条回答
  •  被撕碎了的回忆
    2020-12-03 18:19

    include

    #include 
    
    #include 
    
    #define _XOPEN_SOURCE
    
    #include 
    
    int main(int argc, char **argv) 
    {
    char *slavename;
    int masterfd;
    masterfd = open("/dev/ptmx", O_RDWR);
    grantpt(masterfd);
    unlockpt(masterfd);
    slavename = ptsname(masterfd);
    ...
    }
    

    I posted simple example of demonstrating pseudo terminal master slave concept. please go through this link to get clear understanding of terminals in Linux http://www.linusakesson.net/programming/tty/

提交回复
热议问题