{
  "slug": "tee-system-call",
  "term": "tee (Linux system call)",
  "aliases": [
    "tee(2)"
  ],
  "definition": "The Linux tee system call duplicates up to a given number of bytes from one pipe into another without consuming the data in the source pipe.",
  "note": "Both descriptors must refer to pipes, and to different pipes, otherwise the call fails with EINVAL. Duplicated data stays in the input pipe, so a later splice(2) can move it elsewhere. A return of 0 means no data is available and no writers remain on the input pipe. SPLICE_F_MOVE and SPLICE_F_MORE currently have no effect, and SPLICE_F_NONBLOCK yields EAGAIN instead of blocking. [tee]\n\nDuplication retains references rather than creating independent payload snapshots, because the kernel grabs a reference to the input buffers instead of copying bytes. This is distinct from the user-facing tee command and from trusted execution environments abbreviated TEE. [tee]\n\nThe amount that can be duplicated is bounded by what the input pipe holds. Default pipe capacity is 16 pages, or 65,536 bytes with 4096-byte pages, and F_SETPIPE_SZ can change it. [pipe7]",
  "status": "shipping",
  "advantages": [
    {
      "text": "One pipe stream can feed two consumers without a round trip through userspace memory.",
      "citationIds": [
        "tee"
      ]
    }
  ],
  "limitations": [
    {
      "text": "The interface is Linux-specific, available since Linux 2.6.17 and glibc 2.5, and is not part of POSIX.",
      "citationIds": [
        "tee"
      ]
    },
    {
      "text": "Since Linux 4.5 the default pipe capacity can fall below 16 pages when a per-user soft limit is exceeded.",
      "citationIds": [
        "pipe7"
      ]
    }
  ],
  "related": [
    "splice",
    "sendfile",
    "zero-copy",
    "checksum"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "citations": [
    {
      "id": "tee",
      "title": "Linux man-pages 6.19: tee(2), duplication without consuming and shared references",
      "url": "https://www.man7.org/linux/man-pages/man2/tee.2.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "hesela-lifetime",
      "title": "Hesela: Two consumers can disagree after tee(2)",
      "url": "https://hesela.com/analyses/zero-copy-source-lifetime/#tee-consumers",
      "accessed": "2026-10-18"
    },
    {
      "id": "pipe7",
      "title": "Linux man-pages 6.19: pipe(7), pipe capacity",
      "url": "https://man7.org/linux/man-pages/man7/pipe.7.html",
      "accessed": "2026-10-23"
    }
  ],
  "updated": "2026-10-23",
  "provenance": [
    "tee is the Linux man-pages 6.19 tee(2) page, re-read for descriptor rules, flags, return values, history and the reference-sharing note.",
    "pipe7 is the Linux man-pages 6.19 pipe(7) page, read for default pipe capacity and per-user limits.",
    "A sequential source-mutation experiment with ten observations found that two consumers of duplicated file-backed data can observe different versions, while a buffered-input control kept matching bytes.",
    "The zero-copy entry links here because tee duplicates pipe buffers by reference rather than copying payload bytes."
  ]
}
