[netcf-devel] [PATCH 3/4] * src/netcf.c (run_program): properly check for error; report error details
David Lutterkort
lutter at redhat.com
Tue Sep 15 17:54:28 UTC 2009
---
src/netcf.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/netcf.c b/src/netcf.c
index 2907349..ad88c62 100644
--- a/src/netcf.c
+++ b/src/netcf.c
@@ -244,21 +244,21 @@ int ncf_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
int run_program(struct netcf *ncf, const char *const *argv) {
- int command_return;
+ int status, success;
char *argv_str = argv_to_string(argv);
int ret = -1;
- ERR_NOMEM(argv_str == NULL, ncf);
-
/* BIG FIXME!!! Before any general release, this *must* be
* replaced with a call to a function similar to libVirt's
* virRun(), and if there is an error returned, anything the
* program produced on stderr or stdout should be placed in
* ncf->errdetails.
*/
- command_return = system(argv_str);
-
- ERR_COND_BAIL(command_return != WEXITSTATUS (0), ncf, EEXEC);
+ status = system(argv_str);
+ success = WIFEXITED(status) && WEXITSTATUS(status) == 0;
+ ERR_THROW(!success, ncf, EEXEC,
+ "Running '%s' failed with error code %d",
+ argv_str == NULL ? argv[0] : argv_str, WEXITSTATUS(status));
ret = 0;
error:
--
1.6.2.5
More information about the netcf-devel
mailing list