Re-instate the missing fstat call.
By some bizarre coincidence, this function declared a 'struct stat',
and failed to initialize it, but in practice the uninitialized memory
was in the exact same place on the stack as the struct stat from a
previous call to fstat, which meant all the tests worked :-)
Also, apparently gcc doesn't warn about uninitialised use of structure
fields.
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
- * $Id: lockFile.c,v 1.1 2001/05/18 16:54:06 simonmar Exp $
+ * $Id: lockFile.c,v 1.2 2001/05/21 11:02:15 simonmar Exp $
*
* stdin/stout/stderr Runtime Support
*/
int
lockFile(int fd, int for_writing, int exclusive)
{
- int i;
struct stat sb;
+ int i;
+
+ while (fstat(fd, &sb) < 0) {
+ if (errno != EINTR) {
+#ifndef _WIN32
+ return -1;
+#else
+ /* fstat()ing socket fd's seems to fail with CRT's fstat(),
+ so let's just silently return and hope for the best..
+ */
+ return 0;
+#endif
+ }
+ }
if (for_writing) {
/* opening a file for writing, check to see whether