1.11 Jobs and Processes
Each C program executable, when executed creates a process. Unix can maintain multiple processes at the same time. Each process is a job executed by the shell. To see what current jobs are running in your environment, we type
$ jobs -l
To see what processes are running in the background of your environment, we type
$ ps
PID TTY TIME CMD
2265 pts/0 00:00:01 bash
124554 pts/0 00:00:00 ps
Any process can be killed by using the command
$ kill PID --- PID is the process ID
How to Killing a Process ?
It is very common that as we do programming assignments in this course, we run into situations where program does not terminate. This can be caused by an infinite loop or some weird behavior in the program. In such cases, we need to forcefully terminate the program by using
Control C
1、Ctrl + C
kills the foreground process. If you press (杀死前景进程。如果您按Ctrl + C)
2、Cntrl + Z
then the current process is placed in the background and shell returns a prompt. (然后,当前进程被放在后台,shell返回一个提示符。 )
3、fg
You can bring background processes to foreground by typing (您可以通过键入fg
将后台进程带到前台 )
$ fg
4、Or find the process ID using ps and kill the process.