What’s the difference between a file descriptor and a file pointer?

A file descriptor is a low-level integer “handle” used to identify an opened file (or socket, or whatever) at the kernel level, in Linux and other Unix-like systems. You pass “naked” file descriptors to actual Unix calls, such as read(), write() and so on. A FILE pointer is a C standard library-level construct, used to … Read more

Golang bad file descriptor

You need to add the O_WRONLY flag : if f, err := os.OpenFile(“./log.log”, os.O_APPEND|os.O_WRONLY, os.ModeAppend); err != nil { /*[…]*/ } To explain, here is the linux documentation for open: http://man7.org/linux/man-pages/man2/openat.2.html : The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR. These request opening the file read- only, write-only, … Read more

Getting the highest allocated file descriptor

While portable, closing all file descriptors up to sysconf(_SC_OPEN_MAX) is not reliable, because on most systems this call returns the current file descriptor soft limit, which could have been lowered below the highest used file descriptor. Another issue is that on many systems sysconf(_SC_OPEN_MAX) may return INT_MAX, which can cause this approach to be unacceptably … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)