exec on a guest now returns the return value of the executed process

This commit is contained in:
Tobias Brunner
2008-07-31 12:59:59 +00:00
parent 6dbce9c803
commit 5e9346ed92
3 changed files with 141 additions and 64 deletions
+4 -3
View File
@@ -194,13 +194,14 @@ static VALUE guest_exec(VALUE self, VALUE cmd)
{
guest_t *guest;
bool block;
int ret;
block = rb_block_given_p();
Data_Get_Struct(self, guest_t, guest);
if (guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL,
"%s", StringValuePtr(cmd)) != 0)
if ((ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL,
"%s", StringValuePtr(cmd))) != 0)
{
rb_raise(rb_eRuntimeError, "executing command failed");
rb_raise(rb_eRuntimeError, "executing command failed (%d)", ret);
}
return self;
}