1

When I activate the yes program, it does not react to the CTRL+Z pause (nor to CTRL+C to stop it).

I know no other ways to run a program in the background than using CTRL+Z and then a bg.

  • 2
    What are you trying to do? By "activate" do you just mean run? Are you piping the output of yes somewhere? Or redirecting it? The "yes" program will definitely respond to ^C or ^Z but it's possible that the flood of output it's generating means it'll take a while for the interrupt/pause to take effect. – mmusante May 23 '15 at 19:40
4

An ampersand at the end of a command will cause the command to be run in the background right from the start:

yes &

yes should respond to CTRL+C and definitely CTRL+Z, though. Maybe it's just taking a while for it to take effect for some reason.

  • The only result I get when, eg. CTRL+Cing while the yes is on, is getting ^C briefly printed, and then y ad infinitum. yes & only makes the command start with a half-second delay. Long waiting, and still no sign of yes hiding in the background or ending. – dziadek1990 May 23 '15 at 19:42
  • 1
    You are conflating running in the background with not generating output. Hint: tostop – JdeBP May 23 '15 at 19:50
  • @dziadek1990 yes & (running yes in the background) won't make it end or not output to the current terminal ad infinitum. That's the expected behavior. What are you trying to achieve? – PSkocik May 23 '15 at 19:55
  • @PSkocik Okay, thanks, :) I understand now what yes & is supposed to do. But still yes does not react to my CTRL+C -- now what I want to achieve is to be able to turn off the yes program with that key combination, which for some reason does not work. How can I find out the reasons for those keys not working? – dziadek1990 May 23 '15 at 20:02
  • 1
    @PSkocik Problem solved; apparently I accidentally deleted some system files previously, which caused this and other problems. Thanks for the offered help anyways. :) – dziadek1990 May 24 '15 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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