util: properly detect ttyname_r() failing
This commit is contained in:
parent
116205924e
commit
618e02c7b7
|
@ -2531,11 +2531,12 @@ char* getlogname_malloc(void) {
|
||||||
|
|
||||||
int getttyname_malloc(char **r) {
|
int getttyname_malloc(char **r) {
|
||||||
char path[PATH_MAX], *p, *c;
|
char path[PATH_MAX], *p, *c;
|
||||||
|
int k;
|
||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
||||||
if (ttyname_r(STDIN_FILENO, path, sizeof(path)) < 0)
|
if ((k = ttyname_r(STDIN_FILENO, path, sizeof(path))) != 0)
|
||||||
return -errno;
|
return -k;
|
||||||
|
|
||||||
char_array_0(path);
|
char_array_0(path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue