/*
- * Copyright (C) 2008-2009 Tobias Brunner
+ * Copyright (C) 2008-2010 Tobias Brunner
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
block = rb_block_given_p();
Data_Get_Struct(self, guest_t, guest);
- if ((ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL,
- "exec %s", StringValuePtr(cmd))) != 0)
- {
- rb_raise(rb_eRuntimeError, "executing command failed (%d)", ret);
- }
+ ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL,
+ "exec %s", StringValuePtr(cmd));
+ rb_iv_set(self, "@execstatus", INT2NUM(ret));
return self;
}
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, "pop_overlay", guest_pop_overlay, 0);
+
+ rb_define_attr(rbc_guest, "execstatus", 1, 0);
}
/**
=begin
- Copyright (C) 2008-2009 Tobias Brunner
+ Copyright (C) 2008-2010 Tobias Brunner
Hochschule fuer Technik Rapperswil
This program is free software; you can redistribute it and/or modify it
end
Guest[id]
end
-
+
# accessor for interfaces
# e.g. guest.eth0 instead of guest["eth0"]
def method_missing(id, *args)
end
self[id]
end
-
+
# remove all overlays, delete all interfaces
def reset
while pop_overlay; end
i.delete
}
end
-
+
# has the guest booted up?
def booted?
- begin
- exec("pgrep getty")
- rescue
- return false
- end
- return true
+ exec("pgrep getty")
+ execstatus == 0
end
-
+
# wait until the guest has booted
def boot
while not booted?