After using the file, the process should use the close system call.
This system call usually takes some arguments indicating a file path, the kind of access requested on the file (read, write, append, etc.) and how the file information should be interpreted (text, binary, record-based). In several operating systems this system call can also be used to create a non existent file and returning a file descriptor for it.
int open (const char *pathname, int oflag, .../*,mode_t mode */);
The value returned is the new file descriptor (in POSIX, file descriptors are non-negative integer values). This integer is usually an index on a table of open files for the process. The operating system keeps independent tables for different processes. The file descriptor contains, among other things, a position pointer that indicates which place of the file will be acted upon by further file operations.
The same filesystem file can be opened simultaneously by several processes, and even by the same process (resulting in several file descriptors for the same file). Operations on the descriptors like moving the file pointer, or closing it are independent (they do not affect other descriptors for the same physical file). However, operations of the physical file (like a write) can be seen by operations on the other descriptors (a posterior read can read the written data)
Alternatively, open can return a negative number indicating that the open operation failed
The pathname argument is the name of the file to open. It is a file path indicating in which place of the file system the file should be found (or created if that is requested)
There are a multiple options for this function, which are specified by the oflag argument.
This argument formed by OR'ing together one or more of the following constants (from Optionally, you can also use the following parameters (the following list is not exhaustive, it intends to show what kind of options can be used with open):O_APPEND
the mode_t argument is optional, and is relevant only when creating a new file. It indicates the
file permissions for the newly created file.
References