mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
util: Always pass a pid to virProcessSetMax*()
Currently, the functions accept either an explicit pid or zero, in which case the current process should be modified: the latter might sound like a convenient little feature, but in reality obtaining the pid of the current process is a single additional function call away, so it hardly makes a difference. Removing the few cases in which we're passing zero will allow us to simplify and improve the functions later. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
fe82fdfb52
commit
3d44a809c2
@ -793,11 +793,13 @@ virExec(virCommandPtr cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pid = getpid();
|
||||||
|
|
||||||
if (cmd->pidfile) {
|
if (cmd->pidfile) {
|
||||||
int pidfilefd = -1;
|
int pidfilefd = -1;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
pidfilefd = virPidFileAcquirePath(cmd->pidfile, false, getpid());
|
pidfilefd = virPidFileAcquirePath(cmd->pidfile, false, pid);
|
||||||
if (pidfilefd < 0)
|
if (pidfilefd < 0)
|
||||||
goto fork_error;
|
goto fork_error;
|
||||||
if (virSetInherit(pidfilefd, true) < 0) {
|
if (virSetInherit(pidfilefd, true) < 0) {
|
||||||
@ -817,14 +819,14 @@ virExec(virCommandPtr cmd)
|
|||||||
/* pidfilefd is intentionally leaked. */
|
/* pidfilefd is intentionally leaked. */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virProcessSetMaxMemLock(0, cmd->maxMemLock) < 0)
|
if (virProcessSetMaxMemLock(pid, cmd->maxMemLock) < 0)
|
||||||
goto fork_error;
|
goto fork_error;
|
||||||
if (virProcessSetMaxProcesses(0, cmd->maxProcesses) < 0)
|
if (virProcessSetMaxProcesses(pid, cmd->maxProcesses) < 0)
|
||||||
goto fork_error;
|
goto fork_error;
|
||||||
if (virProcessSetMaxFiles(0, cmd->maxFiles) < 0)
|
if (virProcessSetMaxFiles(pid, cmd->maxFiles) < 0)
|
||||||
goto fork_error;
|
goto fork_error;
|
||||||
if (cmd->setMaxCore &&
|
if (cmd->setMaxCore &&
|
||||||
virProcessSetMaxCoreSize(0, cmd->maxCore) < 0)
|
virProcessSetMaxCoreSize(pid, cmd->maxCore) < 0)
|
||||||
goto fork_error;
|
goto fork_error;
|
||||||
|
|
||||||
if (cmd->hook) {
|
if (cmd->hook) {
|
||||||
|
Loading…
Reference in New Issue
Block a user