goto cleanup;
if (pid > 0) {
- if ((rc = virFileWritePid(LXC_STATE_DIR, name, pid)) != 0) {
- virReportSystemError(rc,
+ if ((rc = virFileWritePid(LXC_STATE_DIR, name, pid)) < 0) {
+ virReportSystemError(-rc,
_("Unable to write pid file '%s/%s.pid'"),
LXC_STATE_DIR, name);
_exit(1);
unlink(sockpath);
VIR_FREE(sockpath);
- return rc;
+ return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}
goto cleanup;
/* And get its pid */
- if ((r = virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) != 0) {
- virReportSystemError(r,
+ if ((r = virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) < 0) {
+ virReportSystemError(-r,
_("Failed to read pid file %s/%s.pid"),
driver->stateDir, vm->def->name);
goto cleanup;
* pid
*/
- if (virFileReadPid(NETWORK_PID_DIR, network->def->name,
- &network->dnsmasqPid) < 0)
+ ret = virFileReadPid(NETWORK_PID_DIR, network->def->name,
+ &network->dnsmasqPid);
+ if (ret < 0)
goto cleanup;
ret = 0;
/* wait for qemu process to show up */
if (ret == 0) {
- if (virFileReadPidPath(priv->pidfile, &vm->pid)) {
+ if (virFileReadPidPath(priv->pidfile, &vm->pid) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Domain %s didn't show up"), vm->def->name);
ret = -1;
}
if (pid > 0) {
- if (pidfile && virFileWritePidPath(pidfile,pid)) {
+ if (pidfile && (virFileWritePidPath(pidfile,pid) < 0)) {
kill(pid, SIGTERM);
usleep(500*1000);
kill(pid, SIGTERM);
char *pidfile = NULL;
if (name == NULL || dir == NULL) {
- rc = EINVAL;
+ rc = -EINVAL;
goto cleanup;
}
if (virFileMakePath(dir) < 0) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
if (!(pidfile = virFilePid(dir, name))) {
- rc = ENOMEM;
+ rc = -ENOMEM;
goto cleanup;
}
if ((fd = open(pidfile,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR)) < 0) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
if (!(file = VIR_FDOPEN(fd, "w"))) {
- rc = errno;
+ rc = -errno;
VIR_FORCE_CLOSE(fd);
goto cleanup;
}
if (fprintf(file, "%d", pid) < 0) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
cleanup:
if (VIR_FCLOSE(file) < 0)
- rc = errno;
+ rc = -errno;
return rc;
}
*pid = 0;
if (!(file = fopen(path, "r"))) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
if (fscanf(file, "%d", pid) != 1) {
- rc = EINVAL;
+ rc = -EINVAL;
VIR_FORCE_FCLOSE(file);
goto cleanup;
}
if (VIR_FCLOSE(file) < 0) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
*pid = 0;
if (name == NULL || dir == NULL) {
- rc = EINVAL;
+ rc = -EINVAL;
goto cleanup;
}
if (!(pidfile = virFilePid(dir, name))) {
- rc = ENOMEM;
+ rc = -ENOMEM;
goto cleanup;
}
char *pidfile = NULL;
if (name == NULL || dir == NULL) {
- rc = EINVAL;
+ rc = -EINVAL;
goto cleanup;
}
if (!(pidfile = virFilePid(dir, name))) {
- rc = ENOMEM;
+ rc = -ENOMEM;
goto cleanup;
}
if (unlink(pidfile) < 0 && errno != ENOENT)
- rc = errno;
+ rc = -errno;
cleanup:
VIR_FREE(pidfile);
goto cleanup;
}
- if (virFileReadPid(abs_builddir, "commandhelper", &pid) != 0) {
+ if (virFileReadPid(abs_builddir, "commandhelper", &pid) < 0) {
printf("cannot read pidfile\n");
goto cleanup;
}
}
alarm(0);
- if (virFileReadPid(abs_builddir, "commandhelper", &pid) != 0) {
+ if (virFileReadPid(abs_builddir, "commandhelper", &pid) < 0) {
printf("cannot read pidfile\n");
goto cleanup;
}