Hi.
I was struggling with a pre-release problem of my mailer, which
has an increasing test coverage, and was head banging on OpenBSD.
(And i was wondering whether i should have Cc:'d Philip Guenther
for this exact problem, but i lost his email address -- Sorry!)
/* There are problems with dup()ing of file-descriptors for child processes.
* We have to somehow accomplish that the FILE* fp makes itself comfortable
* with the *real* offset of the underlaying file descriptor.
* POSIX Issue 7 overloaded fflush(3): if used on a readable stream, then
*
* if the file is not already at EOF, and the file is one capable of
* seeking, the file offset of the underlying open file description shall
* be set to the file position of the stream */
#if defined _POSIX_VERSION && _POSIX_VERSION + 0 >= 200809L
# define n_real_seek(FP,OFF,WH) \
(fseek(FP, OFF, WH) != -1 && fflush(FP) != EOF)
# define really_rewind(stream) \
do{\
rewind(stream);\
fflush(stream);\
}while(0)
#else
# define n_real_seek(FP,OFF,WH) \
(fseek(FP, OFF, WH) != -1 && fflush(FP) != EOF &&\
lseek(fileno(FP), OFF, WH) != -1)
# define really_rewind(stream) \
do{\
rewind(stream);\
fflush(stream);\
lseek(fileno(stream), 0, SEEK_SET);\
}while(0)
#endif
My problems vanish on OpenBSD 6.6, 6.5 and 6.4 if the above
conditional blacklists OpenBSD, as in
#if !su_OS_OPENBSD &&\
defined _POSIX_VERSION && _POSIX_VERSION + 0 >= 200809L
A nice Christmas time i wish,
Ciao,
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)