datacamp / shellwhat

https://shellwhat.readthedocs.io
GNU Affero General Public License v3.0
2 stars 8 forks source link

Implement way to test use of ^C in shell courses #39

Open filipsch opened 6 years ago

filipsch commented 6 years ago

@gvwilson commented on Thu May 17 2018

From https://github.com/datacamp/courses-intro-to-unix-shell/issues/131: if the user types cat > output.txt instead of cat input.txt > output.txt, the command hangs up waiting for user input. We ask them to do something like this at one point in order to teach them how to use ^C to stop programs, but their ^C isn't passed to the SCT, so we have no way to check if they used it or not.

machow commented 6 years ago

From glancing at the exercise, which is titled "How can I stop a running program?", it seems like one alternative is that the exercise starts a running program in the PEC. Then, any student that stops it (causing the SCT to run) has successfully stopped a running program.

In bash specific language, it sounds like this question is asking how to tell a student has sent the SIGINT signal. So if that's the goal, then running a program that only closes for SIGINT seems like it would do it.

If you really didn't want to run a program in PEC, you could run PEC to trap SIGINT:

https://stackoverflow.com/questions/15785522/catch-sigint-in-bash-handle-and-ignore