Advanced Process Management, Memory Layout, and Stack/Heap Flashcards
(40 cards)
What command starts a low-priority background process?
nice
What command changes the priority of a running process?
renice
How do you keep a process running even after logout?
nohup myProgram &
What does fork() do?
Creates a child process.
What does a return value of < 0 from fork() indicate?
Fork failed.
What does a return value of 0 from fork() indicate?
Child process.
What does a return value > 0 from fork() indicate?
Parent process (value = child’s PID).
What do both parent and child processes share?
stdout
- File descriptors
- Global/static variables (as copies)
What does waitpid() do?
Wait for a child process to finish.
What can waitpid() wait for?
- A specific child (pid)
- Any child (pid = 0)
- Return immediately if no child has exited (WNOHANG)
What does exec() do?
Replaces the current process with a new one.
What happens if exec succeeds?
Nothing after it runs.
What happens if exec fails?
Handle the error.
What does pipe() do?
Facilitates communication between parent and child processes.
What are the characteristics of pipes?
- Unbuffered
- Unidirectional
- Must be created before fork()
What does SIGINT represent?
Ctrl+C
Is SIGTERM catchable?
Yes
Is SIGKILL catchable?
No
What are SIGUSR1 and SIGUSR2?
Custom user signals.
What does SIGSEGV represent?
Segfault
What command is used to send a signal?
kill or signal()
What tool is used to create a process?
fork()
What tool is used to replace a process?
exec()
What tool is used to wait for a process?
waitpid()