+int unit_watch_pid_str(Unit *u, const char *s, bool exclusive) {
+ _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
+ int r;
+
+ assert(u);
+ assert(s);
+
+ r = pidref_set_pidstr(&pidref, s);
+ if (r < 0)
+ return r;
+
+ return unit_watch_pidref(u, &pidref, exclusive);
+}
+
+void unit_unwatch_pidref(Unit *u, PidRef *pid) {
+ assert(u);
+ assert(pidref_is_set(pid));
+
+ /* Remove from the set we maintain for this unit. (And destroy the returned pid eventually) */
+ _cleanup_(pidref_freep) PidRef *pid1 = set_remove(u->pids, pid);
+ if (!pid1)
+ return; /* Early exit if this PID was never watched by us */
+
+ /* First let's drop the unit from the simple hash table, if it is included there */
+ PidRef *pid2 = NULL;
+ Unit *uu = hashmap_get2(u->manager->watch_pids, pid, (void**) &pid2);
+
+ /* Quick validation: iff we are in the watch_pids table then the PidRef object must be the same as in our local pids set */
+ assert((uu == u) == (pid1 == pid2));
+
+ if (uu == u)
+ /* OK, we are in the first table. Let's remove it there then, and we are done already. */
+ assert_se(hashmap_remove_value(u->manager->watch_pids, pid2, uu) == uu);
+ else {
+ /* We weren't in the first table, then let's consult the 2nd table that points to an array */
+ PidRef *pid3 = NULL;
+ Unit **array = hashmap_get2(u->manager->watch_pids_more, pid, (void**) &pid3);
+
+ /* Let's iterate through the array, dropping our own entry */
+ size_t m = 0, n = 0;
+ for (; array && array[n]; n++)