diff options
Diffstat (limited to 'libbb/getpty.c')
-rw-r--r-- | libbb/getpty.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libbb/getpty.c b/libbb/getpty.c index 6a15cff2f..435e4d09f 100644 --- a/libbb/getpty.c +++ b/libbb/getpty.c | |||
@@ -19,20 +19,22 @@ int FAST_FUNC xgetpty(char *line) | |||
19 | if (p > 0) { | 19 | if (p > 0) { |
20 | grantpt(p); /* chmod+chown corresponding slave pty */ | 20 | grantpt(p); /* chmod+chown corresponding slave pty */ |
21 | unlockpt(p); /* (what does this do?) */ | 21 | unlockpt(p); /* (what does this do?) */ |
22 | #ifndef HAVE_PTSNAME_R | 22 | # ifndef HAVE_PTSNAME_R |
23 | const char *name; | 23 | { |
24 | name = ptsname(p); /* find out the name of slave pty */ | 24 | const char *name; |
25 | if (!name) { | 25 | name = ptsname(p); /* find out the name of slave pty */ |
26 | bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)"); | 26 | if (!name) { |
27 | bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)"); | ||
28 | } | ||
29 | safe_strncpy(line, name, GETPTY_BUFSIZE); | ||
27 | } | 30 | } |
28 | safe_strncpy(line, name, GETPTY_BUFSIZE); | 31 | # else |
29 | #else | ||
30 | /* find out the name of slave pty */ | 32 | /* find out the name of slave pty */ |
31 | if (ptsname_r(p, line, GETPTY_BUFSIZE-1) != 0) { | 33 | if (ptsname_r(p, line, GETPTY_BUFSIZE-1) != 0) { |
32 | bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)"); | 34 | bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)"); |
33 | } | 35 | } |
34 | line[GETPTY_BUFSIZE-1] = '\0'; | 36 | line[GETPTY_BUFSIZE-1] = '\0'; |
35 | #endif | 37 | # endif |
36 | return p; | 38 | return p; |
37 | } | 39 | } |
38 | #else | 40 | #else |