diff options
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/bsd-misc.c | 16 | ||||
-rw-r--r-- | openbsd-compat/bsd-misc.h | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index f7187daf8..3daf61071 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c | |||
@@ -308,3 +308,19 @@ getsid(pid_t pid) | |||
308 | } | 308 | } |
309 | #endif | 309 | #endif |
310 | 310 | ||
311 | #ifdef FFLUSH_NULL_BUG | ||
312 | #undef fflush | ||
313 | int _ssh_compat_fflush(FILE *f) | ||
314 | { | ||
315 | int r1, r2, r3; | ||
316 | |||
317 | if (f == NULL) { | ||
318 | r2 = fflush(stdout); | ||
319 | r3 = fflush(stderr); | ||
320 | if (r1 == -1 || r2 == -1 || r3 == -1) | ||
321 | return -1; | ||
322 | return 0; | ||
323 | } | ||
324 | return fflush(f); | ||
325 | } | ||
326 | #endif | ||
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index fb81e6c72..52ec52853 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h | |||
@@ -153,4 +153,8 @@ pid_t getsid(pid_t); | |||
153 | int flock(int, int); | 153 | int flock(int, int); |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | #ifdef FFLUSH_NULL_BUG | ||
157 | # define fflush(x) (_ssh_compat_fflush(x)) | ||
158 | #endif | ||
159 | |||
156 | #endif /* _BSD_MISC_H */ | 160 | #endif /* _BSD_MISC_H */ |