Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

does the head call attached to the pipe stop tail from reading the rest of the file after STARTOFFSET+MAXLENGTH?


It does. tail will get SIGPIPE and exit. https://stackoverflow.com/q/8369506

But tail might read up to pipe buffer size more data than is actually required. Also tail + head approach have an overhead of copying data between processes.


That’s why tail | head isn’t a reliable way to seek an fd — it will seek past the desired offset by reading and then failing to write up to PIPEBUF bytes.


Yes, head exits when it's output enough. This causes tail to also call it quits as it has nothing to write to.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: