What's the difference between a foreground program and a background?

I tried to run the program in background and foreground,

in the background it failed to execute,

but in foreground mode it succeeded,

what is the difference between background and foreground mode that can cause this problem?

0


a source to share


2 answers


The foreground process has terminal access (standard input and output).

You can fix the problem by adding <> /dev/null

to the command line. This will tell the program not to use stdin. Some programs accept this and "behave" as soon as you no longer give them a terminal.



Another solution is a program nohup

that does basically the same thing plus a few more things.

+2


a source


Background processes usually run with little or no user interaction, they interact with the system. Background processes are what the user interacts with. Background processes, if not explicitly executed, run with permissions other than admin. If you run it under your custom context, it will most likely have rights to do what the application does.



+1


a source







All Articles