Skip to content

Commit

Permalink
[answerback] align implementation with POSIX-2008
Browse files Browse the repository at this point in the history
- 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
majnemer committed Jan 1, 2011
1 parent 26a9ecd commit 0ab12b7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions answerback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0ab12b7

Please sign in to comment.