Store the exit code of executed commands in Dumm::Guest.execstatus.
Also, no exception is risen for failed exec calls, anymore.
This commit is contained in:
+6
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2008-2009 Tobias Brunner
|
* Copyright (C) 2008-2010 Tobias Brunner
|
||||||
* Copyright (C) 2008 Martin Willi
|
* Copyright (C) 2008 Martin Willi
|
||||||
* Hochschule fuer Technik Rapperswil
|
* Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
@@ -240,11 +240,9 @@ static VALUE guest_exec(VALUE self, VALUE cmd)
|
|||||||
|
|
||||||
block = rb_block_given_p();
|
block = rb_block_given_p();
|
||||||
Data_Get_Struct(self, guest_t, guest);
|
Data_Get_Struct(self, guest_t, guest);
|
||||||
if ((ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL,
|
ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL,
|
||||||
"exec %s", StringValuePtr(cmd))) != 0)
|
"exec %s", StringValuePtr(cmd));
|
||||||
{
|
rb_iv_set(self, "@execstatus", INT2NUM(ret));
|
||||||
rb_raise(rb_eRuntimeError, "executing command failed (%d)", ret);
|
|
||||||
}
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,6 +409,8 @@ static void guest_init()
|
|||||||
rb_define_method(rbc_guest, "add_overlay", guest_add_overlay, 1);
|
rb_define_method(rbc_guest, "add_overlay", guest_add_overlay, 1);
|
||||||
rb_define_method(rbc_guest, "del_overlay", guest_del_overlay, 1);
|
rb_define_method(rbc_guest, "del_overlay", guest_del_overlay, 1);
|
||||||
rb_define_method(rbc_guest, "pop_overlay", guest_pop_overlay, 0);
|
rb_define_method(rbc_guest, "pop_overlay", guest_pop_overlay, 0);
|
||||||
|
|
||||||
|
rb_define_attr(rbc_guest, "execstatus", 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
=begin
|
=begin
|
||||||
Copyright (C) 2008-2009 Tobias Brunner
|
Copyright (C) 2008-2010 Tobias Brunner
|
||||||
Hochschule fuer Technik Rapperswil
|
Hochschule fuer Technik Rapperswil
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
||||||
@@ -43,12 +43,8 @@ module Dumm
|
|||||||
|
|
||||||
# has the guest booted up?
|
# has the guest booted up?
|
||||||
def booted?
|
def booted?
|
||||||
begin
|
exec("pgrep getty")
|
||||||
exec("pgrep getty")
|
execstatus == 0
|
||||||
rescue
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# wait until the guest has booted
|
# wait until the guest has booted
|
||||||
|
|||||||
Reference in New Issue
Block a user