diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-08-16 21:25:09 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-08-16 21:25:09 +0200 |
commit | 618e02c7b7f8e11fdb954a019342d745937baf55 (patch) | |
tree | cca97d81a7dfba97dc11311a7665590a1400d6d5 /src | |
parent | 116205924ef498ab42df233c57e1c4357618ed8a (diff) |
util: properly detect ttyname_r() failing
Diffstat (limited to 'src')
-rw-r--r-- | src/util.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c index bc227f52d5..3bcce2f019 100644 --- a/src/util.c +++ b/src/util.c @@ -2531,11 +2531,12 @@ char* getlogname_malloc(void) { int getttyname_malloc(char **r) { char path[PATH_MAX], *p, *c; + int k; assert(r); - if (ttyname_r(STDIN_FILENO, path, sizeof(path)) < 0) - return -errno; + if ((k = ttyname_r(STDIN_FILENO, path, sizeof(path))) != 0) + return -k; char_array_0(path); |