Skip to content

Commit

Permalink
Flush a stream of stdout explicitly
Browse files Browse the repository at this point in the history
Without flushing a stream which is a socket on exit, buffered outputs
are lost.

This seems to be a bug of OS/2 kLIBC.

Fixed #6.

    modified:   builtin/credential-store.c
  • Loading branch information
komh committed Jun 16, 2024
1 parent 8d8b915 commit d551f33
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions builtin/credential-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ static void print_entry(struct credential *c)
{
printf("username=%s\n", c->username);
printf("password=%s\n", c->password);
/*
* OS/2 kLIBC requires to flush a stream explicitly when it is a socket.
* Otherwise, buffered outputs are lost.
*/
fflush(stdout);
}

static void print_line(struct strbuf *buf)
Expand Down

0 comments on commit d551f33

Please sign in to comment.