if ((pid = virFork()) < 0)
goto cleanup;
if (pid == 0) {
+ int status;
+
if (setlabel &&
virDomainLxcEnterSecurityLabel(secmodel,
seclabel,
NULL,
0) < 0)
- _exit(255);
+ _exit(EXIT_CANCELED);
if (virDomainLxcEnterNamespace(dom,
nfdlist,
NULL,
NULL,
0) < 0)
- _exit(255);
+ _exit(EXIT_CANCELED);
/* Fork a second time because entering the
* pid namespace only takes effect after fork
*/
if ((pid = virFork()) < 0)
- _exit(255);
+ _exit(EXIT_CANCELED);
if (pid == 0) {
execv(cmdargv[0], cmdargv);
- _exit(255);
- } else {
- if (virProcessWait(pid, NULL, false) < 0)
- _exit(255);
+ _exit(errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
}
- _exit(0);
+ if (virProcessWait(pid, &status, true) < 0)
+ _exit(EXIT_CANNOT_INVOKE);
+ virProcessExitWithStatus(status);
} else {
for (i = 0; i < nfdlist; i++)
VIR_FORCE_CLOSE(fdlist[i]);
VIR_FREE(fdlist);
- if (virProcessWait(pid, NULL, false) < 0)
+ if (virProcessWait(pid, NULL, false) < 0) {
+ vshReportError(ctl);
goto cleanup;
+ }
}
ret = true;
passing the requested args. The binary path is relative to the container
root filesystem, not the host root filesystem. The binary will inherit the
environment variables / console visible to virsh. This command only works
-when connected to the LXC hypervisor driver.
+when connected to the LXC hypervisor driver. This command succeeds only
+if C</path/to/binary> has 0 exit status.
=back
=head1 COPYRIGHT
-Copyright (C) 2005, 2007-2010 Red Hat, Inc., and the authors listed in the
+Copyright (C) 2005, 2007-2014 Red Hat, Inc., and the authors listed in the
libvirt AUTHORS file.
=head1 LICENSE