ptytest.c 305 B

12345678910111213141516171819
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. int main()
  7. {
  8. int fd;
  9. char *cp;
  10. fd=open("/dev/ptmx",O_NOCTTY|O_RDWR);
  11. cp=ptsname(fd);
  12. if (cp==NULL)
  13. return EXIT_FAILURE;
  14. printf("ptsname %s\n",cp);
  15. return EXIT_SUCCESS;
  16. }