Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

As I have done multiple times before, I've written bash scripts, and just general commands that go nowhere. They just blink the little command line cursor at me for infinity until I control+C the command. When I do cancel the command, what exactly is going on when I do this? Am I somehow stopping and killing the current PID I'm working on? Does it jump to a different run-level and execute something to terminate the command?

On a slightly different note, I've never been able to figure out how to set up something like this in a script or program I've worked on. Since I mostly program in Ruby, can I setup something like a certain key press stops the program? Every time I've looked into doing something similar, I always end up getting hung up when it comes to user input, whether that is a loop waiting for a condition, or something like this:

def Break()
  user_break = gets.strip
end

def Main()
Function1()
Break()
Function2()
Break()
[...]
end

It seems and is incredibly bulky, and definitely isn't easily scaled up or down.

share|improve this question

1 Answer 1

I would suggest you to read:

You question has already been explained here well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.