Guest User

Untitled

a guest
Jul 24th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. bool openPts(char* ptsName, int* mpty, int* spty) {
  2.  
  3. if (openpty(mpty, spty, ptsName, NULL, NULL) == -1) {
  4. printf("openPts: ERROR openpty [%d] %s",
  5. errno, strerror(errno));
  6. return false;
  7. }
  8.  
  9. // if (*mpty == 0 || *spty == 0) {
  10. // printf("openPts: ERROR openpty mpty[%d] spty[%d] [%d] %s",
  11. // *mpty, *spty, errno, strerror(errno));
  12. //
  13. // if (*mpty > 0) {
  14. // close(*mpty);
  15. // }
  16. // if (*spty > 0) {
  17. // close(*spty);
  18. // }
  19. // return false;
  20. // }
  21.  
  22. ///////////////////////////////////////////////////////////////////
  23. //Set non-blocking
  24. if (setNonblock(*mpty) == -1) {
  25. printf("openPts: mpty[%d] NONBLOCK ERROR [%d] [%s]",
  26. *mpty, errno, strerror(errno));
  27. }
  28. if (setNonblock(*spty) == -1) {
  29. printf("openPts: spty[%d] NONBLOCK ERROR [%d] [%s]",
  30. *spty, errno, strerror(errno));
  31. }
  32. ///////////////////////////////////////////////////////////////////
  33. printf("openPts[%s]: fd MASTER[%d] fd SLAVE[%d]",
  34. ptsName, *mpty, *spty);
  35.  
  36. return true;
  37. }
Add Comment
Please, Sign In to add comment