Skip to content

Commit 36ffba1

Browse files
committed
sideband: avoid short write(2)
The sideband demultiplexor writes the data it receives on sideband with xwrite(). We can lose data if the underlying write(2) results in a short write. If they are limited to unimportant bytes like eye-candy progress meter, it may be OK to lose them, but lets be careful and ensure that we use write_in_full() instead. Note that the original does not check for errors, and this rewrite does not check for one. At least not yet. Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa6c383 commit 36ffba1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sideband.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ int demultiplex_sideband(const char *me, int status,
220220
}
221221

222222
strbuf_addch(scratch, *brk);
223-
xwrite(2, scratch->buf, scratch->len);
223+
write_in_full(2, scratch->buf, scratch->len);
224224
strbuf_reset(scratch);
225225

226226
b = brk + 1;
@@ -247,7 +247,7 @@ int demultiplex_sideband(const char *me, int status,
247247
die("%s", scratch->buf);
248248
if (scratch->len) {
249249
strbuf_addch(scratch, '\n');
250-
xwrite(2, scratch->buf, scratch->len);
250+
write_in_full(2, scratch->buf, scratch->len);
251251
}
252252
strbuf_release(scratch);
253253
return 1;

0 commit comments

Comments
 (0)