0

Wanted to know what happens to the global file table and inode table when I do dup()

I know it returns an int, and it opens a new file descriptor in the file descriptor table

sdafad
  • 359
  • 1
  • 2
  • 7

1 Answers1

1

The dup call does not alter the inode or any system table. It only alters the file descriptor table which is a process related table.

I think these 2 questions might help you understand what dup actually does. Difference between creating a duplicate file descriptor using dup() and creating a hard link? dup2 / dup - why would I need to duplicate a file descriptor?

Bottom-line : Dup doesn't affect the system in anyway , just the process.

Community
  • 1
  • 1
Avner Solomon
  • 1,486
  • 11
  • 17
  • so when u dup, wont it affect de descriptor table? – sdafad Jun 24 '13 at 20:41
  • it does affect the descriptor table. But that table is only per process table. Each process when created is assigned various stuff by the OS ( a pid , a fd (file descriptor table) etc. in *nix systems). That's why creating a process always takes longer than creating a thread (the process creation overhead). Still dup won't affect inodes or other system data. – Avner Solomon Jun 24 '13 at 20:45