Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Comments on Check if piped-in process is blocked on input

Post

Check if piped-in process is blocked on input

+1
−0

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?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

What exactly are you trying to achieve? Why does it matter whether the first process is blocked by in... (2 comments)
What exactly are you trying to achieve? Why does it matter whether the first process is blocked by in...
celtschk‭ wrote 12 days ago

What exactly are you trying to achieve? Why does it matter whether the first process is blocked by input, stopped, waiting for a network resource, or simply taking time to calculate the output?

Karl Knechtel‭ wrote 10 days ago

I'm thinking of making a "commander"-style program, and one of the things I'd like to do is display output inline in a terminal window if it's all generated up front, but automatically background the process and handle it in a separate window if it requires input (so that the user can go back to writing terminal commands immediately, but later interact with the interactive program).

I didn't really consider other cases for non-immediate output. I think I want to try showing the text inline first, wait patiently, but then move it if it reaches an input block. The primary goal is to handle interactive programs differently, automatically.

Of course, it might be different for cases like this, where my own bar program can spawn foo and connect to its IO streams. Maybe I asked the wrong question.