In POSIX, why is the open system call declared in fcntl.h, while the close system call is declared in unistd.h? I presume this is a historical artifact, but this pair strikes me as especially odd since you often need to close after open.
h is the header in the C POSIX library for the C programming language that contains constructs that refer to file control, e.g. opening a file, retrieving and changing the permissions of file, locking a file for edit, etc.
No, unistd. h and fcntl. h , etc are not part of standard C.
As previously pointed out, sockets and pipes also get passed to close. But probably the original reason is that open needs flags like O_RDONLY that are defined in fcntl.h, so you might as well put the prototype in that file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With