diff options
Diffstat (limited to 'pty.c')
| -rw-r--r-- | pty.c | 12 |
1 files changed, 6 insertions, 6 deletions
| @@ -22,22 +22,22 @@ getpty(void) { | |||
| 22 | ptm = open("/dev/ptmx", O_RDWR); | 22 | ptm = open("/dev/ptmx", O_RDWR); |
| 23 | if(ptm == -1) | 23 | if(ptm == -1) |
| 24 | if(openpty(&ptm, &pts, NULL, NULL, NULL) == -1) | 24 | if(openpty(&ptm, &pts, NULL, NULL, NULL) == -1) |
| 25 | eprintn("error, cannot open pty"); | 25 | err(EXIT_FAILURE, "cannot open pty"); |
| 26 | #endif | 26 | #endif |
| 27 | #if defined(_XOPEN_SOURCE) | 27 | #if defined(_XOPEN_SOURCE) |
| 28 | if(ptm != -1) { | 28 | if(ptm != -1) { |
| 29 | if(grantpt(ptm) == -1) | 29 | if(grantpt(ptm) == -1) |
| 30 | eprintn("error, cannot grant access to pty"); | 30 | err(EXIT_FAILURE, "cannot grant access to pty"); |
| 31 | if(unlockpt(ptm) == -1) | 31 | if(unlockpt(ptm) == -1) |
| 32 | eprintn("error, cannot unlock pty"); | 32 | err(EXIT_FAILURE, "cannot unlock pty"); |
| 33 | ptsdev = ptsname(ptm); | 33 | ptsdev = ptsname(ptm); |
| 34 | if(!ptsdev) | 34 | if(!ptsdev) |
| 35 | eprintn("error, slave pty name undefined"); | 35 | err(EXIT_FAILURE, "slave pty name undefined"); |
| 36 | pts = open(ptsdev, O_RDWR); | 36 | pts = open(ptsdev, O_RDWR); |
| 37 | if(pts == -1) | 37 | if(pts == -1) |
| 38 | eprintn("error, cannot open slave pty"); | 38 | err(EXIT_FAILURE, "cannot open slave pty"); |
| 39 | } | 39 | } |
| 40 | else | 40 | else |
| 41 | eprintn("error, cannot open pty"); | 41 | err(EXIT_FAILURE, "cannot open pty"); |
| 42 | #endif | 42 | #endif |
| 43 | } | 43 | } |
