kern/164793: 'write' system call violates POSIX standard
nicolas.bourdaud at gmail.com
Wed Feb 15 13:40:11 UTC 2012
The following reply was made to PR standards/164793; it has been noted by GNATS.
From: Nicolas Bourdaud <nicolas.bourdaud at gmail.com>
To: Bruce Evans <brde at optusnet.com.au>
Cc: freebsd-gnats-submit at FreeBSD.org, freebsd-bugs at FreeBSD.org
Subject: Re: kern/164793: 'write' system call violates POSIX standard
Date: Wed, 15 Feb 2012 14:13:31 +0100
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
Content-Type: text/plain; charset=ISO-8859-1
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 =3D 0;
>> const char pattern[PATTSIZE] =3D "Hello world!";
>> signal(SIGXFSZ, SIG_IGN);
>> lim.rlim_cur =3D 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:
just before "lim.rlim_cur =3D LIMSIZE;"
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
More information about the freebsd-bugs