Linux Processes Flashcards

1
Q

Process Creation

A

A process can be created from other processes, which is used very frequently in linux.

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

exec()

A

Allows us to execute one process from another process, leading the child process to take over. For example, in user system calls, we can call the execl() function to run another program in our program we have created, like execl(“/bin/ls”, “ls”, “-l”, NULL). This gives the location of the process and the process name, with NULL indicating the end of the parameters being passed.

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

fork()

A

Allows us to clone the original process, so that we can alter the cloned process without alternating the original. This cloned process is also a child process, and takes over. For example, when a user logs in and starts a graphical session, the login manager may use fork() to create a child process to handle the user’s session.

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

wait()

A

This allows us to stop the parent process when fork() or exec() is called until the child process is done.

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

The first process in linux

A

Systemd is the first process in linux. When executed, it continues to run in the background, offering on-demand spawning of other services/processes, maintaining log files and keeping track of other processes and kernel settings.

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

GRUB

A

GNU Grand Unified Bootloader. Stored in ROM and is a set of processes which help set up Linux when first loaded up, specifically loading the Linux kernel into memory and passing control to it, as well as configuring the system hardware and initializing the system services.

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

sshd

A

Secure shell daemon application; spawned by systemd. This is responsible for managing oncoming ssh connections (ssh is used to connect to a linux server). This uses the system calls fork() and exec() for the login process.

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

Login Process with sshd

A

1) We use ssh to connect to linux server
2) The sshd daemon uses fork() to spawn a child process
3) The child uses exec() to run login process
4) The login process checks credentials
5) Then the login process uses exec() to run our preferred shell process

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

Zombies and Orphans

A

Zombies -> if a parent does not execute the wait() syscall, it will continue to terminate during the execution of the child process. Once the child has finished, there is no wait() syscall so the parent has continued and therefore does not require a signal to terminate the child. This gives us a zombie process, which is a child that has finished and needs to be terminated, but cannot be.
Orphan -> we also have the same situation that if there is no wait() called, and the parent finishes its process before the child, the child has no parent and becomes an orphan.
Systemd performs wait() on the zombies and orphans, which instructs them to return their exit status, terminating them.

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

Daemons

A

These processes normally run in the background, performing background operations of the OS, like subsystem managers. These needs their own time on the CPU, and run with higher priority (this is in connection with the OS requiring time on the CPU).

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

Linux Signals and Responses to Signals

A

These interrupt signals are sent between processes with the syscall signal(), and can be used to terminate a process. For example, to terminate a process we input kill -s SIGKILL …
These signals can be responded to one of three ways:
- performing the action
- ignoring the signal
- catch the signal and run some other code instead
There is one signal which cannot be ignored/caught, however, which is SIGKILL.

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

Using Linux Signals for Zombies

A

We can actually use SIGKILL to kill the parent of the zombie. This way, the systemd will adopt the zombie and call wait().

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

Inter-Process Communications and Examples

A

Communications between processes. Four examples include:
- shared memory
- shared files
- pipes
- sockets

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

Shared memory and files

A

Allows two processes to access the same memory location or file at the same time, which can cause synchronisation issues and requires semaphores and locks.

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

Pipes

A

Form of IPC between two children who have the same parent, normally triggered by typing a command at the prompt. We can join two processes via the | symbol.

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

Sockets

A

Form of IPC that can span multiple systems, with one process being the server, or daemon, and the other being the client thats connected to the server.
This type of communication is bidirectional, and implemented as special files in the file system.
These processes don’t need to be on the same machine, an the server process uses the listen() syscall to wait for clients.

17
Q

List of SIG commands

A

SIGKILL -> Request to terminate process.
SIGINT -> Interrupted from keyboard, like ctrl+c.
SIGTERM -> Request to terminate process but may be ignored.
SIGCHLD -> Indicates child process termination.
SIGIO -> Indicates input or output is ready.