"/bin/rm -rf %s",
cloudInitTmpDirPath);
command[sizeof(command) - 1] = '\0';
- ForkExecAndWaitCommand(command, false);
+ if (ForkExecAndWaitCommand(command, false) != 0) {
+ sLog(log_warning,
+ "Error while removing temporary folder '%s'. (%s)\n",
+ cloudInitTmpDirPath, strerror(errno));
+ }
}
sLog(log_error, "Setting generic error status in vmx.\n");
SetCustomizationStatusInVmx(TOOLSDEPLOYPKG_RUNNING,
close(pkgFd);
return FALSE;;
}
- lseek(pkgFd, sizeof(VMwareDeployPkgHdr), 0);
- while((rdCount = read(pkgFd, copyBuf, sizeof copyBuf)) > 0) {
+ if (lseek(pkgFd, sizeof(VMwareDeployPkgHdr), 0) == (off_t) -1) {
+ sLog(log_error,
+ "Failed to set the offset for the package file '%s'. (%s)\n",
+ pkgName, strerror(errno));
+ close(pkgFd);
+ close(zipFd);
+ ret = FALSE;
+ goto done;
+ }
+ while ((rdCount = read(pkgFd, copyBuf, sizeof copyBuf)) > 0) {
if (write(zipFd, copyBuf, rdCount) < 0) {
- sLog(log_warning, "write() failed.\n");
+ sLog(log_error, "Failed to write the zip file '%s'. (%s)\n", zipName,
+ strerror(errno));
+ close(pkgFd);
+ close(zipFd);
+ ret = FALSE;
+ goto done;
}
}
}
Process_Destroy(h);
+done:
+ // Clean up the temporary zip file
+ if (remove(zipName) != 0) {
+ sLog(log_warning, "Failed to remove the temporary zip file '%s'. (%s)\n",
+ zipName, strerror(errno));
+ }
return ret;
}
p->stdoutFd = stdout[0];
flags = fcntl(p->stdoutFd, F_GETFL);
- fcntl(p->stdoutFd, F_SETFL, flags | O_NONBLOCK);
+ if (fcntl(p->stdoutFd, F_SETFL, flags | O_NONBLOCK) == -1) {
+ p->log(log_warning, "Failed to set stdoutFd status flags, (%s)",
+ strerror(errno));
+ }
p->stderrFd = stderr[0];
flags = fcntl(p->stderrFd, F_GETFL);
- fcntl(p->stderrFd, F_SETFL, flags | O_NONBLOCK);
+ if (fcntl(p->stderrFd, F_SETFL, flags | O_NONBLOCK) == -1) {
+ p->log(log_warning, "Failed to set stderrFd status flags, (%s)",
+ strerror(errno));
+ }
elapsedTimeLoopSleeps = 0;