#define _XOPEN_SOURCE 600 #include #include #include #include #include #include #define check(x) if ((x) == -1) { \ perror(#x); \ exit(1); \ } int main() { int ptymfd = posix_openpt(O_RDWR); check(ptymfd); check(grantpt(ptymfd)); check(unlockpt(ptymfd)); char *slavename = ptsname(ptymfd); printf("pty = %s\n", slavename); while (1) { char ch; int r = read(ptymfd, &ch, 1); check(r); if ('A' <= ch && ch < 'Z') ch++; int w = write(ptymfd, &ch, 1); check(w); } return EXIT_SUCCESS; }