--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+
+/* Licensed under the GPL
+ * Copyright (c) Miek Gieben, 2006
+ */
+
+/* like tee(1), but then connect to other programs using
+ * pipes _and_ output to standard output
+ */
+
+void
+close_pipes(FILE **p, size_t i)
+{
+ size_t j;
+ for (j = 0; j < i; j++)
+ pclose(p[j]);
+}
+
+int
+main(int argc, char **argv) {
+ size_t i, r;
+ FILE **pipes;
+ char buf[BUFSIZ];
+
+ pipes = malloc(((argc - 1) * sizeof *pipes));
+ if (!pipes)
+ exit(EXIT_FAILURE);
+
+ for (i = 1; i < argc; i++) {
+ pipes[i - 1] = popen(argv[i], "w");
+ if (!pipes[i - 1]) {
+ fprintf(stderr, "Can not open pipe to '%s\'\n", argv[i]);
+ close_pipes(pipes, i);
+
+ exit(EXIT_FAILURE);
+ }
+ }
+ argc--;
+
+ while(!feof(stdin) && (!ferror(stdin))) {
+ r = fread(buf, sizeof(char), BUFSIZ, stdin);
+ for(i = 0; i < argc; i++) {
+ if (fwrite(buf, sizeof(char), r, pipes[i]) != r) {
+ fprintf(stderr, "Write error to `%s\'\n", argv[i + 1]);
+ close_pipes(pipes, i);
+ exit(EXIT_FAILURE);
+ }
+ fwrite(buf, sizeof(char), r, stdout);
+ }
+ }
+ close_pipes(pipes, argc);
+
+ exit(EXIT_SUCCESS);
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+
+Copyright 2006 Joey Hess <joey@kitenet.net>
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+-->
+
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.4//EN"
+"file:///usr/share/xml/docbook/schema/dtd/4.4/docbookx.dtd"
+[]>
+
+<refentry>
+ <refentryinfo>
+ <address>
+ <email>joey@kitenet.net</email>
+ </address>
+ <author>
+ <firstname>Joey</firstname>
+ <surname>Hess</surname>
+ </author>
+ <date>2006-03-14</date>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>pee</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>pee</refname>
+ <refpurpose>tee standard input to pipes</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>pee</command>
+ <group choice="opt">
+ <arg rep="repeat"><replaceable>"command"</replaceable></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>DESCRIPTION</title>
+
+ <para><command>pee</command> is like <command>tee</command>
+ but for pipes. Each command is run and standard input is
+ copied into it, as well as being sent to stdout.</para>
+
+ </refsect1>
+
+ <refsect1>
+ <title>SEE ALSO</title>
+
+ <para>
+ <citerefentry>
+ <refentrytitle>tee</refentrytitle><manvolnum>1</manvolnum>
+ </citerefentry>
+ </para>
+
+ </refsect1>
+</refentry>