GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Sync(3) User Contributed Perl Documentation Sync(3)

File::Sync - Perl access to fsync() and sync() function calls

  use File::Sync qw(fsync sync);
  sync();
  fsync(\*FILEHANDLE) or die "fsync: $!";
  # and if fdatasync() is available on your system:
  fdatasync($fh) or die "fdatasync: $!";
  use File::Sync qw(fsync);
  use FileHandle;
  $fh = new FileHandle("> /tmp/foo") 
      or die "new FileHandle: $!";
  ...
  $fh->fsync() or die "fsync: $!";

The fsync() function takes a Perl file handle as its only argument, and passes its fileno() to the C function fsync(). It returns undef on failure, or true on success. fdatasync() is identical in return value, but it calls C fdatasync() instead of fsync(), synchronizing only the data in the file, not the metadata.

The fsync_fd() function is used internally by fsync(); it takes a file descriptor as its only argument.

The sync() function is identical to the C function sync().

This module does not export any methods by default, but fsync() is made available as a method of the FileHandle class. Note carefully that as of 0.11, we no longer clobber anything in IO::Handle. You can replace any calls to IO::Handle::fsync() with IO::Handle::sync():
https://rt.cpan.org/Public/Bug/Display.html?id=50418

Doing fsync() if the stdio buffers aren't flushed (with $| or the autoflush method) is probably pointless.

Calling sync() too often on a multi-user system is slightly antisocial.

Carey Evans <c.evans@clear.net.nz>

perl(1), fsync(2), sync(2), perlvar(1)

2011-11-19 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.