Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is HANDLE similar to file descriptor in Linux?

Tags:

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

like image 340
Amumu Avatar asked Nov 01 '11 10:11

Amumu


People also ask

Is file descriptor same as file handle?

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.

What is a handle in Linux?

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.

What are file handles in Linux?

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.

What are the three file descriptors in Linux?

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).


1 Answers

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

like image 79
Mark Seaborn Avatar answered Oct 21 '22 18:10

Mark Seaborn