dundalek / closh

Bash-like shell based on Clojure
Eclipse Public License 1.0
1.62k stars 67 forks source link

handle Ctrl-C #30

Closed mnewt closed 6 years ago

mnewt commented 6 years ago

Closh doesn't process Ctrl-C while a command is running (maybe it doesn't pass it to the child process?). And when Ctrl-C is pressed at the prompt it exits (is that read-line trapping it?).

$ sleep 10
<press Ctrl-C>
<10 seconds later>
$
<closh exits>

Expected outcome is:

  1. Ctrl-C interrupts a child process
  2. At the prompt, Ctrl-C clears whatever, if anything, is written on the command line but otherwise does nothing. This is just my preference as it's the way fish does it and it's nice. The alternative of moving to a new prompt line (like bash) would also work.
dundalek commented 6 years ago

Definitely high on the list. We need to handle these things: 1) Interrupt when clojure code is running (lumo repl does this so I will look for inspiration there) 2) Send SIGINT signal to the child process (if a command is running) 3) Cancel the pipeline

I agree when no command is running then clearing the command line would be nice.

mnewt commented 6 years ago

I started testing some of this in node (without lumo). Unfortunately, lumo has a bug where it doesn't respect SIGINT traps (https://github.com/anmonteiro/lumo/issues/191).

After that is dealt with, it looks like we will need to use node's startSigintWatchdog (https://github.com/nodejs/node/blob/master/src/node_util.cc) to trap during execution.

dundalek commented 6 years ago

Implemented and released in 0.2.0.