Guest User

Untitled

a guest
Sep 4th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <errno.h>
  4.  
  5. int main(void)
  6. {
  7. int fdm;
  8. int rc;
  9.  
  10. // Display /dev/pts
  11. system("ls -l /dev/pts");
  12.  
  13. fdm = posix_openpt(O_RDWR);
  14. if (fdm < 0)
  15. {
  16. fprintf(stderr, "Error %d on posix_openpt()\n", errno);
  17. return 1;
  18. }
  19.  
  20. rc = grantpt(fdm);
  21. if (rc != 0)
  22. {
  23. fprintf(stderr, "Error %d on grantpt()\n", errno);
  24. return 1;
  25. }
  26.  
  27. rc = unlockpt(fdm);
  28. if (rc != 0)
  29. {
  30. fprintf(stderr, "Error %d on unlockpt()\n", errno);
  31. return 1;
  32. }
  33.  
  34. // Display the changes in /dev/pts
  35. system("ls -l /dev/pts");
  36.  
  37. printf("The slave side is named : %s\n", ptsname(fdm));
  38.  
  39. return 0;
  40. } // main
Advertisement
Add Comment
Please, Sign In to add comment