Source file src/internal/poll/fd_fsync_darwin.go

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package poll
     6  
     7  import (
     8  	"internal/syscall/unix"
     9  	"syscall"
    10  )
    11  
    12  // Fsync invokes SYS_FCNTL with SYS_FULLFSYNC because
    13  // on OS X, SYS_FSYNC doesn't fully flush contents to disk.
    14  // See Issue #26650 as well as the man page for fsync on OS X.
    15  func (fd *FD) Fsync() error {
    16  	if err := fd.incref(); err != nil {
    17  		return err
    18  	}
    19  	defer fd.decref()
    20  	return ignoringEINTR(func() error {
    21  		_, err := unix.Fcntl(fd.Sysfd, syscall.F_FULLFSYNC, 0)
    22  		return err
    23  	})
    24  }
    25  

View as plain text