X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=unit.c;h=900c76ad66a1aa47c468d94aba0d125629b4ff3c;hp=872abf3e13d6920a2a84cce92a354f91b1f034df;hb=ac86f50d7b62fb16b4521c87bd2739b9c26a4f60;hpb=4f2d528d3bb25cebf8d3ebe83d8193ab4016cb90 diff --git a/unit.c b/unit.c index 872abf3e1..900c76ad6 100644 --- a/unit.c +++ b/unit.c @@ -1023,6 +1023,9 @@ int unit_watch_pid(Unit *u, pid_t pid) { assert(u); assert(pid >= 1); + /* Watch a specific PID. We only support one unit watching + * each PID for now. */ + return hashmap_put(u->meta.manager->watch_pids, UINT32_TO_PTR(pid), u); } @@ -1030,7 +1033,7 @@ void unit_unwatch_pid(Unit *u, pid_t pid) { assert(u); assert(pid >= 1); - hashmap_remove(u->meta.manager->watch_pids, UINT32_TO_PTR(pid)); + hashmap_remove_value(u->meta.manager->watch_pids, UINT32_TO_PTR(pid), u); } int unit_watch_timer(Unit *u, usec_t delay, Watch *w) { @@ -1606,6 +1609,23 @@ fail: return NULL; } +int unit_watch_bus_name(Unit *u, const char *name) { + assert(u); + assert(name); + + /* Watch a specific name on the bus. We only support one unit + * watching each name for now. */ + + return hashmap_put(u->meta.manager->watch_bus, name, u); +} + +void unit_unwatch_bus_name(Unit *u, const char *name) { + assert(u); + assert(name); + + hashmap_remove_value(u->meta.manager->watch_bus, name, u); +} + static const char* const unit_type_table[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = "service", [UNIT_TIMER] = "timer",