dup 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. .TH DUP 3
  2. .SH NAME
  3. dup \- dups of open files
  4. .SH SYNOPSIS
  5. .nf
  6. .B bind #d /fd
  7. .B /fd/0
  8. .B /fd/0ctl
  9. .B /fd/1
  10. .B /fd/1ctl
  11. \&...
  12. .fi
  13. .SH DESCRIPTION
  14. The
  15. .I dup
  16. device serves a one-level directory containing files whose
  17. names are decimal numbers.
  18. Each such file also has an associated control file.
  19. A file of name
  20. .I n
  21. corresponds to open file descriptor
  22. .I n
  23. in the current process.
  24. .PP
  25. An
  26. .IR open (2)
  27. of file
  28. .I n
  29. results in a file descriptor identical to
  30. what would be returned from a system call
  31. .IB dup ( n ,
  32. .BR -1) .
  33. Note that the result is no longer a file in the
  34. .I dup
  35. device.
  36. .PP
  37. The
  38. .I stat
  39. operation returns information about the device file, not the open file it points to.
  40. A stat of
  41. .BI #d/ n
  42. will contain
  43. .I n
  44. for the name, 0 for the length, and 0400, 0200, or 0600
  45. for the mode, depending on whether the dup target is open
  46. for reading, writing, or both.
  47. .PP
  48. A file of name
  49. .IB n ctl
  50. may be read to discover the properties of the associated file descriptor, in format identical to that of the
  51. .B fd
  52. file in
  53. .IR proc (3).
  54. .SH SEE ALSO
  55. .IR dup (2)
  56. .SH SOURCE
  57. .B /sys/src/9/port/devdup.c