return s;
}
+int manager_allocate_idle_pipe(Manager *m) {
+ int r;
+
+ assert(m);
+
+ if (m->idle_pipe[0] >= 0) {
+ assert(m->idle_pipe[1] >= 0);
+ assert(m->idle_pipe[2] >= 0);
+ assert(m->idle_pipe[3] >= 0);
+ return 0;
+ }
+
+ assert(m->idle_pipe[1] < 0);
+ assert(m->idle_pipe[2] < 0);
+ assert(m->idle_pipe[3] < 0);
+
+ r = RET_NERRNO(pipe2(m->idle_pipe + 0, O_NONBLOCK|O_CLOEXEC));
+ if (r < 0)
+ return r;
+
+ r = RET_NERRNO(pipe2(m->idle_pipe + 2, O_NONBLOCK|O_CLOEXEC));
+ if (r < 0) {
+ safe_close_pair(m->idle_pipe + 0);
+ return r;
+ }
+
+ return 1;
+}
+
void unit_defaults_init(UnitDefaults *defaults, RuntimeScope scope) {
assert(defaults);
assert(scope >= 0);
LogTarget manager_get_executor_log_target(Manager *m);
+int manager_allocate_idle_pipe(Manager *m);
+
const char* oom_policy_to_string(OOMPolicy i) _const_;
OOMPolicy oom_policy_from_string(const char *s) _pure_;
assert(hashmap_isempty(tr->jobs));
- if (!hashmap_isempty(m->jobs)) {
- /* Are there any jobs now? Then make sure we have the
- * idle pipe around. We don't really care too much
- * whether this works or not, as the idle pipe is a
- * feature for cosmetics, not actually useful for
- * anything beyond that. */
-
- if (m->idle_pipe[0] < 0 && m->idle_pipe[1] < 0 &&
- m->idle_pipe[2] < 0 && m->idle_pipe[3] < 0) {
- (void) pipe2(m->idle_pipe, O_NONBLOCK|O_CLOEXEC);
- (void) pipe2(m->idle_pipe + 2, O_NONBLOCK|O_CLOEXEC);
- }
- }
+ /* Are there any jobs now? Then make sure we have the idle pipe around. We don't really care too much
+ * whether this works or not, as the idle pipe is a feature for cosmetics, not actually useful for
+ * anything beyond that. */
+ if (!hashmap_isempty(m->jobs))
+ (void) manager_allocate_idle_pipe(m);
return 0;
}