This change updates the "rbd device" commands, propagating
rbd-wnbd.exe exit codes.
Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
close(stdout_pipe_in_fd);
close(stderr_pipe_in_fd);
- DWORD status = 0;
+ int status = 0;
if (WaitForSingleObject(proc_handle, INFINITE) != WAIT_FAILED) {
if (!GetExitCodeProcess(proc_handle, &status)) {
errstr << cmd << ": Could not get exit code: " << pid
<< ". Error code: " << GetLastError();
+ status = -ECHILD;
} else if (status) {
errstr << cmd << ": exit status: " << status;
}
} else {
errstr << cmd << ": Waiting for child process failed: " << pid
<< ". Error code: " << GetLastError();
+ status = -ECHILD;
}
close_h(proc_handle);
if (process.spawn()) {
std::cerr << "rbd: failed to run rbd-wnbd: " << process.err() << std::endl;
return -EINVAL;
- } else if (process.join()) {
+ }
+ int exit_code = process.join();
+ if (exit_code) {
std::cerr << "rbd: rbd-wnbd failed with error: " << process.err() << std::endl;
- return -EINVAL;
+ return exit_code;
}
return 0;