reliable reads from pipes

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Aug 5 12:17:27 AEST 1990


In article <1990Aug3.233256.29659 at NCoast.ORG> atul at NCoast.ORG (Atul Parulekar) writes:
>but sometimes it does not print out the full directory name (prints (/) ...

"pwd" doesn't necessarily print its entire output in a single atomic write(),
so your read() on the pipe may return only a portion of what "pwd" will
eventually have written.  The simplest solution is to read until you see a
new-line, which will be the last thing output by "pwd".



More information about the Comp.unix.questions mailing list