commit
646978d9adc5 ("vgdb: Handle EINTR and EAGAIN more
consistently") introduced another off-by-one issue trying to write
back the error from child to parent.
Instead of +1 it should have been +written (which initially is zero).
This is when the child needs to do a chdir and that chdir fails. If
that happens the parent would have gotten the wrong error code.
// We try to write the result to the parent, but always exit.
size_t written = 0;
while (written < sizeof (int)) {
- int nrw = write (pipefd[1], ((char *)&err) + 1,
+ int nrw = write (pipefd[1], ((char *)&err) + written,
sizeof (int) - written);
if (nrw == -1) {
if (errno == EINTR || errno == EAGAIN)