# Shell command handlers

tension do_kill priority 20
  match cmd in proc.CMD_SIG select first
    where cmd.cmd_id == 1
  match proc in proc.CPU0 select first
    where proc.protected == 0
  emit move proc.terminate proc to proc.TERMINATED
  emit move proc.consume_signal cmd to proc.SIG_DONE

tension do_block priority 20
  match cmd in proc.CMD_SIG select first
    where cmd.cmd_id == 6
  match proc in proc.CPU0 select first
    where proc.protected == 0
  emit move proc.block_proc proc to proc.BLOCKED
  emit move proc.consume_signal cmd to proc.SIG_DONE

tension do_unblock priority 20
  match cmd in proc.CMD_SIG select first
    where cmd.cmd_id == 7
  match proc in proc.BLOCKED select first
  emit move proc.unblock proc to proc.READY
  emit move proc.consume_signal cmd to proc.SIG_DONE

tension do_load priority 20
  match cmd in proc.CMD_SIG select first
    where cmd.cmd_id == 2
  match ctl in input.SHELL_STATE
  emit set ctl action cmd.arg_id
  emit move proc.consume_signal cmd to proc.SIG_DONE

tension do_swap priority 20
  match cmd in proc.CMD_SIG select first
    where cmd.cmd_id == 3
  match ctl in input.SHELL_STATE
  emit set ctl action 10
  emit move proc.consume_signal cmd to proc.SIG_DONE

tension do_list priority 20
  match cmd in proc.CMD_SIG select first
    where cmd.cmd_id == 4
  match ctl in input.SHELL_STATE
  emit set ctl action 20
  emit move proc.consume_signal cmd to proc.SIG_DONE

tension do_help priority 20
  match cmd in proc.CMD_SIG select first
    where cmd.cmd_id == 5
  match ctl in input.SHELL_STATE
  emit set ctl action 30
  emit move proc.consume_signal cmd to proc.SIG_DONE

tension do_spawn priority 20
  match cmd in proc.CMD_SIG select first
    where cmd.cmd_id == 8
  match ctl in input.SHELL_STATE
  emit set ctl action 40
  emit move proc.consume_signal cmd to proc.SIG_DONE

tension cmd_miss priority 2
  match cmd in proc.CMD_SIG select first
  match ctl in input.SHELL_STATE
  emit set ctl action -1
  emit move proc.consume_signal cmd to proc.SIG_DONE
