From owner-freebsd-questions@FreeBSD.ORG Fri Jul 22 12:14:39 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE57A106564A for ; Fri, 22 Jul 2011 12:14:39 +0000 (UTC) (envelope-from pieter@degoeje.nl) Received: from smtp.utwente.nl (smtp2.utsp.utwente.nl [130.89.2.9]) by mx1.freebsd.org (Postfix) with ESMTP id 516438FC12 for ; Fri, 22 Jul 2011 12:14:38 +0000 (UTC) Received: from pieter-dev.localnet (lux.student.utwente.nl [130.89.161.112]) by smtp.utwente.nl (8.12.10/SuSE Linux 0.7) with ESMTP id p6MBbGuw023231; Fri, 22 Jul 2011 13:37:16 +0200 From: Pieter de Goeje To: freebsd-questions@freebsd.org Date: Fri, 22 Jul 2011 13:37:15 +0200 User-Agent: KMail/1.13.7 (Linux/2.6.39-2-amd64; KDE/4.6.4; x86_64; ; ) References: <1311317040.38368.YahooMailClassic@web160115.mail.bf1.yahoo.com> In-Reply-To: <1311317040.38368.YahooMailClassic@web160115.mail.bf1.yahoo.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201107221337.15804.pieter@degoeje.nl> X-UTwente-MailScanner-Information: Scanned by MailScanner. Contact icts.servicedesk@utwente.nl for more information. X-UTwente-MailScanner: Found to be clean X-UTwente-MailScanner-From: pieter@degoeje.nl X-Spam-Status: No Cc: Unga Subject: Re: How to sync a file on FreeBSD? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2011 12:14:39 -0000 On Friday, July 22, 2011 08:44:00 AM Unga wrote: > How to sync a file on FreeBSD (esp. on 8.1) to disk? > > I used fsync(2), but does not immediately flush to disk. > > I want my writing to a file (a log file) immediately available to other > users to read. A file doesn't need to be "synced" to disk for other users to read the latest data. The application just needs to call write(2) and the data is available. It will be written to and read from the operating system's file cache. If you're using stdio you can force a write(2) by calling fflush(3). - Pieter