[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#119974: Bug confirmed

Hi, I've just tested this bug, and observed something rather interesting:

% cpp /usr/include/unistd.h |grep fsync
extern int fsync (int __fd)  ;
% cpp -D_POSIX_SOURCE /usr/include/unistd.h | grep fsync

So it gets included in the default header file, but not when _POSIX_SOURCE
is defined. Now according to a little online research[1], I've found out
that fsync() was actually NOT part of POSIX.1, but was introduced in
POSIX.1b.  (There was apparently some controversy surrounding the exact
semantics of fsync(), which may have played a role in its late
introduction to POSIX.)

It may be that the fsync declaration in unistd.h was written before
POSIX.1b, and so it would be excluded when _POSIX_SOURCE was defined. But
I presume the manpages were written/updated after POSIX.1b, and hence they
mark fsync as POSIX-compliant. Regardless, since fsync is now
POSIX-compliant (specifically, POSIX.1b-compliant), <unistd.h> should be

The glibc maintainers should, of course, check the actual POSIX.1b spec to
ensure that this is accurate.

(Also, there may be an issue surrounding old code that expects
_POSIX_SOURCE to refer only to POSIX.1 (as opposed to .1b) compliance, and
so would expect fsync *not* to be defined; but I'm not well informed
enough to know if this is the case or not.) 

[1] I was going to include it here, but it was getting a bit lengthy and
    perhaps not that relevant. But I'll provide it if anybody's


Some ideas are so stupid that only intellectuals could believe them. --
George Orwell

Reply to: