Question: I am piping the output of a program like this using bash:

```
program1 | program2

```

If program2 is killed somehow (in my case by a PHP fatal error), what happens to the instance of program1?

Answer: 
The pipe will be broken and the program writing to the pipe will receive a SIGPIPE signal.

From [GLIBC](http://www.delorie.com/gnu/docs/glibc/libc_477.html):

> 
> SIGPIPE
>  Broken pipe. If you use pipes or FIFOs, you have to design your
>  application so that one process opens
>  the pipe for reading before another
>  starts writing. If the reading process
>  never starts, ***or terminates
>  unexpectedly***, writing to the pipe or
>  FIFO raises a SIGPIPE signal. If
>  SIGPIPE is blocked, handled or
>  ignored, the offending call fails with
>  EPIPE instead.
> 
> 
>
The short answer is that `program1` dies.

`program1` gets a `SIGPIPE` signal when the pipe is broken. Programs designed to be long running daemons usually handle the signal and do proper cleanup, but your typical interactive program does not. The default action is to terminate the program, so for the most part, `program1` will just be terminated.