#endif /* HAVE_READLINE */
+struct supervisor_task {
+ bool stdout_task_started;
+ struct task task;
+};
+
static void supervisor_post_select(struct sched *s, struct task *t)
{
+ struct supervisor_task *svt = container_of(t, struct supervisor_task,
+ task);
+
if (ct->task.error < 0) {
t->error = ct->task.error;
return;
}
- if (ct->status == CL_EXECUTING) {
- stdin_set_defaults(&sit);
- register_task(s, &sit.task);
+ if (!svt->stdout_task_started && ct->status == CL_EXECUTING) {
stdout_set_defaults(&sot);
register_task(s, &sot.task);
+ svt->stdout_task_started = true;
+ return;
+ }
+ if (ct->status == CL_SENDING) {
+ stdin_set_defaults(&sit);
+ register_task(s, &sit.task);
t->error = -E_TASK_STARTED;
return;
}
}
-static struct task svt = {
- .post_select = supervisor_post_select,
- .status = "supervisor task"
+static struct supervisor_task supervisor_task = {
+ .task = {
+ .post_select = supervisor_post_select,
+ .status = "supervisor task"
+ }
};
/**
goto out;
sot.btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = "stdout", .parent = ct->btrn[0]));
- register_task(&sched, &svt);
+ register_task(&sched, &supervisor_task.task);
ret = schedule(&sched);
if (ret >= 0 && ct->task.error < 0) {
switch(ct->task.error) {