Permalink
Browse files

[answerback] align implementation with POSIX-2008

- ctermid() cannot return NULL, it *can* return an empty string tho
- use our own buffer instead of the provided one. this is because some
  implementations choose to malloc the buffer! (this tool is supposed to
  be pretty speedy)
  • Loading branch information...
1 parent 26a9ecd commit 0ab12b757eb9aab515a6d97b66c052fb93103a63 @majnemer committed Jan 1, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 answerback.c
View
@@ -29,9 +29,10 @@ tty_reset(void)
int main()
{
- const char *cterm = ctermid(NULL);
+ char term[L_ctermid];
+ const char *cterm = ctermid(term);
- if (cterm == NULL)
+ if (cterm[0] == '\0')
{
(void)fputs("Cannot get the path to the console", stderr);
return EXIT_FAILURE;

0 comments on commit 0ab12b7

Please sign in to comment.