On 05/02/2012 19:54, Bruce Evans wrote:
> I think this is actually a bug in POSIX (XSI).  Most programs aren't
> prepared to deal with short writes, and returning an error like
> truncate() is specified to is adequate.

I disagree, I think that most programs that check that the write
succeeded also check that the write was complete. Actually it was
because my programs were assuming the POSIX behavior that I notice the
bug. In addition, I think (this must be confirmed) that the bug don't
affect the version 8.2... So the programs are already facing the POSIX
behavior. Moreover the programs that are cross platform (in particular
ported to Linux) are already facing this behavior.

Whatever is decided, either freebsd should conform to the POSIX
standard, either the standard should be changed.


>> Patch attached with submission follows:
>> ...
>> int main(void)
>> {
>>     struct rlimit lim;
>>     int fd;
>>     ssize_t retc;
>>     size_t count = 0;
>>     const char pattern[PATTSIZE] = "Hello world!";
>>
>>     signal(SIGXFSZ, SIG_IGN);
>>     lim.rlim_cur = LIMSIZE;
>>     setrlimit(RLIMIT_FSIZE, &lim);
> 
> This is missing initialization of at least lim.rlim_max in lim.  This
> gave the bizarre behaviour that when the program was statically linked,
> it failed for the first write, because the stack garbage for
> lim.rlim_max happened to be 0.

Yes I forgot one line:
        getrlimit(RLIMIT_FSIZE, &lim);
just before "lim.rlim_cur = LIMSIZE;"

Best regards

Nicolas



Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to