LATEST UPDATE (ALREADY GRADED A+)
File Descriptor
A per-process, unique, nonnegative
integer used to identify an open file for the purposes of file access
Open File Description
A record of how a process or
group of processes are currently accessing a file
- Each file descriptor refers to exactly one open file
description, but an open file description may be referred
to by more than one file descriptor
dup()
Creates a copy of a file descriptor.
- The two file descriptors may be used interchangeably
• It returns a new file descriptor having the following in common with the original file descriptor
- Same open file (or pipe)
- Same file pointer
- Same access mode (read, write, or read/write)
- The new file descriptor is set to remain open across exec
functions
• The file descriptor returned is the lowest numbered
unused descriptor
dup2()
Makes a new file descriptor be the copy of oldfd, closing newfd first if necessary
• There is no time lapse between closing newfd and duplicating oldfd into its spot
Unnamed Pipes
- Used only with related processes
• Parent/child
• Child/child
- Exists only as long as the processes using it are alive
Named Pipes
- Actually exist as directory entries
- Have file access permissions
- Can be used by unrelated processes