Is HANDLE similar to file descriptor in Linux? As far as I know, HANDLE is used for handling every resources on Windows, such as font, icons, files, devices..., which in essence is just a void pointer point to a memory block holding data of a specific resource
From what I have gathered from Wikipedia, a file descriptor is an index in a file descriptor table, which points to a file name in a file table, which in turn points to an inode in an inode table. File handle is a type of data structure that stores a file descriptor.
A handle, hanp, uniquely identifies a filesystem object or an entire filesystem. There is one and only one handle per filesystem or filesystem object. Handles consist of some number of bytes.
File handles (file descriptors) are just integers. Processes use them to index a system table of open files (file descriptions). File handles, unlike filesystem elements, do not reside on or get updated with the filesystem. They're instead used by processes to keep a register of its open files.
Stdin, stdout, and stderr On a Unix-like operating system, the first three file descriptors, by default, are STDIN (standard input), STDOUT (standard output), and STDERR (standard error).
Yes, Windows handles are very similar to Unix file descriptors (FDs).
Note that a HANDLE
is not a pointer to a block of memory. Although HANDLE
is typedef
'd as void *
, that's just to make it more opaque. In practice, a HANDLE
is an index that is looked up in a table, just as an FD number is.
This blog post explores some of the similarities and differences: http://lackingrhoticity.blogspot.com/2015/05/passing-fds-handles-between-processes.html
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