mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
command: Add virCommandExec helper
Actually execs the argv/env we've generated, replacing the current process. Kind of has a limited usage, but allows us to use virCommand in LXC driver to launch the 'init' process
This commit is contained in:
parent
924eb9a4b4
commit
f095398a47
@ -107,6 +107,7 @@ virCommandAddEnvPassCommon;
|
||||
virCommandAddEnvString;
|
||||
virCommandClearCaps;
|
||||
virCommandDaemonize;
|
||||
virCommandExec;
|
||||
virCommandFree;
|
||||
virCommandNew;
|
||||
virCommandNewArgList;
|
||||
|
@ -980,6 +980,28 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exec the command, replacing the current process. Meant to be called
|
||||
* after already forking / cloning, so does not attempt to daemonize or
|
||||
* preserve any FDs.
|
||||
*
|
||||
* Returns -1 on any error executing the command.
|
||||
* Will not return on success.
|
||||
*/
|
||||
int virCommandExec(virCommandPtr cmd)
|
||||
{
|
||||
if (!cmd ||cmd->has_error == ENOMEM) {
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
}
|
||||
if (cmd->has_error) {
|
||||
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("invalid use of command API"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return execve(cmd->args[0], cmd->args, cmd->env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Run the command and wait for completion.
|
||||
|
@ -255,6 +255,16 @@ char *virCommandToString(virCommandPtr cmd) ATTRIBUTE_RETURN_CHECK;
|
||||
*/
|
||||
char *virCommandTranslateStatus(int exitstatus) ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
/*
|
||||
* Exec the command, replacing the current process. Meant to be called
|
||||
* after already forking / cloning, so does not attempt to daemonize or
|
||||
* preserve any FDs.
|
||||
*
|
||||
* Returns -1 on any error executing the command.
|
||||
* Will not return on success.
|
||||
*/
|
||||
int virCommandExec(virCommandPtr cmd) ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
/*
|
||||
* Run the command and wait for completion.
|
||||
* Returns -1 on any error executing the
|
||||
|
Loading…
x
Reference in New Issue
Block a user