9 Job control Flashcards

1
Q

Start command or entire pipe as a background job, without connecting stdin to terminal:

A

$ command &

returns
[shell job id] PID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Job number output by shell

A

Shell prints both a job number (identifying all processes in pipe) as well as process ID of last process in pipe. Shell will list all its jobs with the jobs command, where a + sign marks the last stopped (default) job.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Foreground job

A

Stdin connected to terminal, shell prompt delayed until process exits, keyboard signals delivered to this single job.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Background job

A

Stdin disconnected (read attempt will suspend job), next shell prompt appears immediately, keyboard signals not delivered, shell prints notification when job terminates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Keyboard signals

A

change with stty
32 bit int in PCB - other processes can set them, check+possibly invoke signal handler on each system call performed by the process

Ctrl-C “intr” (SIGINT=2) by default aborts process
Ctrl-\ “quit” (SIGQUIT=3) aborts process with core dump Ctrl-Z “susp” (SIGSTOP=19) suspends process
Another important signal (not available via keyboard): SIGKILL=9 destroys process immediately

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

resume suspended job in foreground

A

fg

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

resume suspended job in background

A

bg

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

send SIGINT to job/process

A

kill

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Arguments to fg/bg/kill

A

no args - acts on [1]+ last process to change state

OR provide:
process ID
% + job number
% + command name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

send sigkill

A

kill -9 …

Should only be used as a last resort, if a normal kill (which sends SIGINT) failed, otherwise program has no chance to clean up resources before it terminates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

see list of jobs of current shell

A

jobs command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

list the entire process table

A

ps
ps -x (many options – check man)
top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

fg %, %

A

run previously stopped job in foreground – allows you to switch between several programs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly