dundalek / closh

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

Run command in the background with & #133

Open dundalek opened 5 years ago

dundalek commented 5 years ago

This might involve needing to implement job control to keep track of running background processes.

djblue commented 4 years ago

@dundalek Did you have any ideas on how job control should be implemented?

dundalek commented 4 years ago

@djblue My thought process is that I don't think I've ever needed the full job control using jobs, fg and bg during all my years with bash. Therefore I would like to try if it is possible to make something simpler.

I imagine we could wrap background processes in a future (to make them run in a separate thread so they don't block in case there is a clojure computation as part of the pipeline). When you want to wait for the the process you just deref the future, which will either give you the result or block until the process completes.

I have a work in progress branch that adds support for the & to the parser. After that it should be just adding the future wrapping part to the compiler code.

What do you think? Is there maybe some use that would be missed out by such approach?