delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/08/23/01:42:52

Date: Wed, 23 Aug 2000 08:43:29 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: snowball3 AT bigfoot DOT com
Message-Id: <968-Wed23Aug2000084329+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.2.emacs20_6 I) and Blat ver 1.8.5b
CC: djgpp-workers AT delorie DOT com
In-reply-to: <39A2ADB4.10320.5F727@localhost> (snowball3@bigfoot.com)
Subject: Re: Problems with depcomp from fileutils 4.0x & bash 2.03
References: <200008220358 DOT JAA01049 AT midpec DOT com> (message from Prashant TR on Tue, 22 Aug 2000 09:28:24 +0530) <39A2ADB4 DOT 10320 DOT 5F727 AT localhost>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "Mark E." <snowball3 AT bigfoot DOT com>
> Date: Tue, 22 Aug 2000 16:43:32 -0400
>   write (fd, document, document_len);
> 
>   /* _dos_commit (fd); */
>   fd2 = open (document, O_RDONLY, 0600);
> 
>   close (fd);
> 
>   /* Process here document in fd2. Won't work unless _dos_commit is uncommented. */
>   close (fd2);
> 
>   return 0;
> }
> 
> Adding a call to '_dos_commit' solves the problem in Bash 2.04 for plain DOS.

It is indeed unsafe to assume that all the data is written to the file
unless you commit it (or close the handle).  In particular, DOS
buffering is not transparent for other handles open for the same file.
Another aspect of the same problem is that stat and fstat don't agree
on file's size until you fsync the handle, after writing to it.

You could use `fsync' instead of _dos_commit, to keep the code
Posix-compliant, btw.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019