0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

modules/console: Add app signal cmd.

This commit is contained in:
Jason Volk 2020-10-28 05:16:48 -07:00
parent e55c750f97
commit ca69e70653

View file

@ -16386,3 +16386,38 @@ console_cmd__app__unload(opt &out, const string_view &line)
out << "not found." << std::endl;
return true;
}
bool
console_cmd__app__signal(opt &out, const string_view &line)
{
const params param{line, " ",
{
"signum", "event_id"
}};
const auto signum
{
param.at<uint>("signum")
};
const auto event_idx
{
lex_castable<m::event::idx>(param.at("event_id"))?
lex_cast<m::event::idx>(param.at("event_id")):
m::index(param.at("event_id"))
};
for(auto *const &app : m::app::list)
if(app->event_idx == event_idx)
{
out << "Signal " << signum;
if(!app->child.signal(signum))
out << " failed";
out << " to PID " << app->child.pid << std::endl;
return true;
}
out << "not found." << std::endl;
return true;
}