1Sync(3)               User Contributed Perl Documentation              Sync(3)
2
3
4

NAME

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

SYNOPSIS

9         use File::Sync qw(fsync sync);
10         sync();
11         fsync(\*FILEHANDLE) or die "fsync: $!";
12         # and if fdatasync() is available on your system:
13         fdatasync($fh) or die "fdatasync: $!";
14
15         use File::Sync qw(fsync);
16         use FileHandle;
17         $fh = new FileHandle("> /tmp/foo")
18             or die "new FileHandle: $!";
19         ...
20         $fh->fsync() or die "fsync: $!";
21

DESCRIPTION

23       The fsync() function takes a Perl file handle as its only argument, and
24       passes its fileno() to the C function fsync().  It returns undef on
25       failure, or true on success. fdatasync() is identical in return value,
26       but it calls C fdatasync() instead of fsync(), synchronizing only the
27       data in the file, not the metadata.
28
29       The fsync_fd() function is used internally by fsync(); it takes a file
30       descriptor as its only argument.
31
32       The sync() function is identical to the C function sync().
33
34       This module does not export any methods by default, but fsync() is made
35       available as a method of the FileHandle class. Note carefully that as
36       of 0.11, we no longer clobber anything in IO::Handle. You can replace
37       any calls to IO::Handle::fsync() with IO::Handle::sync():
38         https://rt.cpan.org/Public/Bug/Display.html?id=50418
39

NOTES

41       Doing fsync() if the stdio buffers aren't flushed (with $| or the
42       autoflush method) is probably pointless.
43
44       Calling sync() too often on a multi-user system is slightly antisocial.
45

AUTHOR

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

SEE ALSO

50       perl(1), fsync(2), sync(2), perlvar(1)
51
52
53
54perl v5.36.0                      2022-07-22                           Sync(3)
Impressum