Post History
Suppose I am the author of a shell utility called bar. One common use case is in pipelines like foo | bar, where foo sometimes runs interactively. I want to distinguish situations where interaction...
#1: Initial revision
Check if piped-in process is blocked on input
Suppose I am the author of a shell utility called `bar`. One common use case is in pipelines like `foo | bar`, where `foo` sometimes runs interactively. I want to distinguish situations where interaction is required from situations where `foo` produces all its output up front and immediately exits. Is it possible from within `bar` to determine a) the process that's piping into it; b) whether that process is blocked on input? If it's possible, what system calls do I need?