Skip to main content
3 of 4
added 86 characters in body
hudac
  • 791
  • 2
  • 7
  • 19

Running process in background ruins terminal

I have this makefile:

all: 
        sudo watch "ls -l" > /dev/null &
        @echo line 1
        @echo line 2
        @echo line 3
        @echo line 4

Running watch (or any other process that somehow changes the terminal) ruins the terminal. This is the output. You can see these big spaces. Also, I can't see the characters afterwards, when I write:

me@me:/tmp$ make
watch "ls -l" > /dev/null &
line 1
line 2
      line 3
            line 4
                  me@me:/tmp$ 

Is there a way to prevent a process changing the terminal?
A clarification: watch is just a reproductible example. I'm using another app that should run as daemon, and still ruins the terminal.


Edit: I start this app (on this example, the app is watch) with sudo

hudac
  • 791
  • 2
  • 7
  • 19