News for hackers. Stuff that matters.
Re:For the Love of Pipes by benj111 on Tuesday January 22, 2019 @07:19AM (#18967730)
Interesting question.

You could write a executable that accepts piped input and throws it away.

When would it exit though? Would it exit successfully at the end of the input stream? That sounds sensible.

That would be behaving like an executable wouldn't it?

Re:For the Love of Pipes by majewsky on Tuesday January 22, 2019 @07:53AM (#18967882)
> When would it exit though? Would it exit successfully at the end of the input stream?

A process that attempts to read from a closed pipe receives SIGPIPE. The default disposition for SIGPIPE is to terminate the program (similar to SIGTERM or SIGINT). So yeah, assuming that the previous program in the pipeline closes its stdout at some point (either explicitly, or implicitly by just exiting), then our program would die of SIGPIPE the when it tries to read() from stdin and the pipe's buffer has been depleted.

However, our program could also set SIGPIPE to ignored and ignore the EPIPE errors that read() would return in that case. In that case, it could run indefinitely. But at this point, you're way past normal behavior.

Re:For the Love of Pipes by jacquesm on Tuesday January 22, 2019 @07:47AM (#18967852)
As long as it does not exit you can still catch it through /proc/