When os.OpenFile is called on Centos6, the O_CLOEXEC flag is set on the file handle. I don't think it is possible to avoid the flag being set. For example, the following call:
f, err := os.OpenFile( "lockfile", os.O_CREATE|os.O_RDWR, 0666 )
looks like this in strace:
[pid 2928] open("lockfile", O_RDWR|O_CREAT|O_CLOEXEC, 0666) = 3
syscall.CloseOnExec is provided to set the close-on-exec flag for a given file handle, but I can't find a corresponding function for clearing the close-on-exec flag.
How can I clear the close-on-exec flag for a file ?