summaryrefslogtreecommitdiff
path: root/src/user/knob/task.c
blob: 598bee2e11d48c54666c116b53bc903d3e685a01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdbool.h>
#include <pland/syscall.h>
#include <knob/file.h>
#include <knob/heap.h>
#include <knob/block.h>

bool try_run_command(const char *path) {
  uint8_t dn;
  path = remove_prefix(path, &dn);

  for (const char *ptr = path; *ptr; ++ptr)
    if (*ptr == ' ') {
      char *new_path = get_block(ptr - path + 1);
      blockcpy(new_path, path, ptr - path);
      new_path[ptr - path] = '\0';

      bool succeded = _start_task(dn, new_path, ptr + 1);
      free_block(new_path);
      return succeded;
    }

  return _start_task(dn, path, "");
}

void yield_task() {
  _yield_task();
}