3 ms·
If you have multiple programs writing to the same terminal, their write calls can get interleaved. To ensure that a single echo command's output remains unbroke
by Camillo 14y ago
If you have multiple programs writing to the same terminal, their write calls can get interleaved. To ensure that a single echo command's output remains unbroken, it should be output using a single write call.
GNU relies on stdio's buffering for this. Plan 9 allocates a buffer for the entire output and copies the arguments there.
FreeBSD wants to avoid linking to stdio, and wants to avoid copying memory (both for reasons of efficiency, presumably), so it uses the writev call instead, which lets you pass the kernel an array of buffers to write, without having to build up a single buffer in advance.