ptytest.c 348 B

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