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

1 Answers1

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.

Petr Skocik
  • 28,816
  • 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? – Petr Skocik 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
  • Give me ssh access to your PC and I'll test it out for ya. No, seriously, it's hard to tell. What kind of terminal and system are you at? – Petr Skocik May 23 '15 at 20:06
  • Fedora-Live-Workstation-x86_64-21-5 (on a VBox VM, if it makes a difference), terminal: xterm-256color -------------- [there will be a possible 24+h delay to your request; other priorities for now] – dziadek1990 May 23 '15 at 20:22
  • 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