[{"id":"linuxbeginner-001","courseId":"linux-beginner","domain":"processes-and-scheduling","topic":"Process IDs and getppid","prompt":"A shell starts the program ./report. Inside report, the code calls getpid() and getppid(). Which statement about the two results is correct?","hint":"One call names the running process itself; the other names the process that created it.","explain":"Each running process has its own ID number. A process was created by another process, and the kernel lets a program read both its own ID and its creator's ID.","source":"https://man7.org/linux/man-pages/man2/getpid.2.html","interaction":{"type":"single"},"options":[{"id":"a","text":"getpid() returns report's own PID, and getppid() returns the PID of the shell that started it","why":"getpid() returns the calling process's PID, and getppid() returns the PID of the process that created it, here the shell."},{"id":"b","text":"getppid() returns report's own PID, and getpid() returns the shell's PID","whyNot":"The two names are swapped: getpid() is the calling process's own ID, not its parent's."},{"id":"c","text":"Both calls return the same number, because a program and the shell that started it share one PID","whyNot":"Each process has its own PID; a child never shares its parent's PID."},{"id":"d","text":"getppid() returns 0 whenever the program was started from a terminal","whyNot":"getppid() returns 0 only when the parent is in a different PID namespace, not because of a terminal."}],"answer":"a","explanation":"getpid() returns the calling process's PID; getppid() returns the PID of its parent, the process that created it.","concept":"getpid() returns the calling process's PID; getppid() returns the PID of its parent, the process that created it.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["getpid() is your own ID; getppid() is the ID of the process that created you."]},{"id":"linuxbeginner-002","courseId":"linux-beginner","domain":"processes-and-scheduling","topic":"fork() copies the caller","prompt":"A program calls fork() once, and both processes keep running. Which TWO statements about the new child process are correct?","hint":"Think about what the child copies from its parent, and what the kernel sets up fresh.","explain":"fork() creates a new process that begins as a copy of the caller. Learn what the copy keeps and what the kernel sets up fresh for the new process.","source":"https://man7.org/linux/man-pages/man2/fork.2.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"It inherits copies of the parent's open file descriptors","why":"The child gets copies of the parent's file descriptors, and each one refers to the same open file description."},{"id":"b","text":"It starts with a single thread, the one that called fork()","why":"Only the calling thread is replicated, so the child begins as a single-threaded process."},{"id":"c","text":"It shares the parent's memory, so a write by either process is seen by the other","whyNot":"The child gets a replica of the parent's address space, so later writes are not shared."},{"id":"d","text":"When it ends, it sends SIGKILL to the parent, so the parent always learns of it","whyNot":"A child's termination signal is always SIGCHLD, not SIGKILL."},{"id":"e","text":"It keeps all of the parent's threads, so both processes have the same thread count","whyNot":"The child is created with one thread, the one that called fork(), not a copy of every thread."},{"id":"f","text":"It is ended automatically when the parent exits, because it cannot outlive its creator","whyNot":"The child does not receive a signal when its parent terminates, so it keeps running."}],"answer":"ab","explanation":"After fork(), the child gets copies of the parent's open file descriptors and its address space, but starts with a single thread and sends SIGCHLD on termination.","concept":"After fork(), the child gets copies of the parent's open file descriptors and its address space, but starts with a single thread and sends SIGCHLD on termination.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["A forked child keeps the parent's open files but starts with just one thread."]},{"id":"linuxbeginner-003","courseId":"linux-beginner","domain":"processes-and-scheduling","topic":"exec() replaces the program","prompt":"A process calls execve() to run /bin/ls. What happens to the calling process's program after a successful call?","hint":"Compare this with creating a second process.","explain":"A process can be given a completely new program to run. The old program's code and data are discarded and replaced with the new program's, and the process keeps running that new program.","source":"https://man7.org/linux/man-pages/man2/execve.2.html","interaction":{"type":"single"},"options":[{"id":"a","text":"It is replaced by ls, and execve() never returns on success","why":"On success the old text and data are overwritten by the new program, so there is no old code left to return to."},{"id":"b","text":"It keeps its own code, and ls runs in a new thread beside it","whyNot":"execve() does not start a thread; it replaces the calling process's program."},{"id":"c","text":"A new process with a new PID runs ls, while the caller keeps its program","whyNot":"That describes fork() followed by exec in the child; execve() itself replaces the caller's program."},{"id":"d","text":"execve() returns ls's exit status to the caller once ls finishes","whyNot":"On success execve() does not return at all, so no exit status comes back to the caller."}],"answer":"a","explanation":"execve() replaces the calling process's program with a new one, overwriting its text and data; it does not return on success.","concept":"execve() replaces the calling process's program with a new one, overwriting its text and data; it does not return on success.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["execve() swaps the program in place; it does not come back on success."]},{"id":"linuxbeginner-004","courseId":"linux-beginner","domain":"processes-and-scheduling","topic":"Signal handler invocation","prompt":"A process has a handler installed for SIGUSR1. Once the kernel starts delivering a SIGUSR1 to the thread, put these four steps in the order they happen.","hint":"Think about where the interrupted thread's state is kept, and what code runs when the handler finishes.","explain":"A signal handler is ordinary user code that runs on the thread it interrupted. The kernel saves enough state to resume that thread later, and a fixed piece of user-space code finishes the job.","source":"https://man7.org/linux/man-pages/man7/signal.7.html","interaction":{"type":"sort","items":[{"text":"The kernel builds a frame on the stack and points the thread at the handler","why":"The frame records the thread's state, and the thread is redirected to the handler with a return address set to the trampoline."},{"text":"The kernel passes control to user space, and the handler's first instruction runs","why":"Execution starts at the handler only after the kernel has set the thread up to run it."},{"text":"When the handler returns, control passes to the signal trampoline","why":"The return address the kernel set up sends control to the trampoline when the handler finishes."},{"text":"The trampoline calls sigreturn(2), which restores the thread to its earlier state","why":"Only after the handler returns does sigreturn use the saved frame to resume the interrupted code."}]},"options":[],"answer":"o:abcd","explanation":"A signal handler runs on the interrupted thread: the kernel builds a frame and redirects the thread, then the trampoline calls sigreturn(2) to restore it after the handler returns.","concept":"A signal handler runs on the interrupted thread: the kernel builds a frame and redirects the thread, then the trampoline calls sigreturn(2) to restore it after the handler returns.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["The kernel runs a handler on the interrupted thread, and sigreturn restores that thread afterwards."]},{"id":"linuxbeginner-005","courseId":"linux-beginner","domain":"processes-and-scheduling","topic":"Uncatchable signals","prompt":"A program ignores SIGTERM and keeps running. Which signal can an administrator send that this program cannot catch, block or ignore?","hint":"Look for the one signal the program has no say over.","explain":"Signals are notices sent to a process. Most signals let the program choose a handler, ignore the signal, or block it. A few signals are enforced by the kernel, and the program has no say over them.","source":"https://man7.org/linux/man-pages/man7/signal.7.html","interaction":{"type":"single"},"options":[{"id":"a","text":"SIGKILL","why":"SIGKILL cannot be caught, blocked or ignored, so the kernel always ends the process when it is sent."},{"id":"b","text":"SIGUSR1","whyNot":"SIGUSR1 is a user-defined signal, and a program can install its own handler for it."},{"id":"c","text":"SIGALRM","whyNot":"SIGALRM is a timer signal that a program can catch with a handler."},{"id":"d","text":"SIGINT","whyNot":"SIGINT is the keyboard interrupt, and a program can catch it to clean up before exiting."}],"answer":"a","explanation":"SIGKILL and SIGSTOP cannot be caught, blocked or ignored, while most other standard signals can be handled by the program.","concept":"SIGKILL and SIGSTOP cannot be caught, blocked or ignored, while most other standard signals can be handled by the program.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["kill -9 (SIGKILL) ends a process even when it ignores every other signal."]}]