Signals and Process Control in Unix/Linux Quiz Quiz

Explore key concepts of process management and signal handling in Unix/Linux systems with this quiz. Assess your understanding of commands, signals, and techniques involved in controlling processes using examples and practical scenarios.

  1. Understanding UNIX Signals

    Which signal is sent by default when the 'kill' command is used without specifying a signal, such as in 'kill 1234'?

    1. SIGSTOP
    2. SIGTERM
    3. SIGKILL
    4. SIGCONT

    Explanation: The default signal sent by the 'kill' command is SIGTERM, which requests the process to terminate gracefully. SIGKILL would force termination but must be explicitly specified, such as 'kill -9 1234'. SIGSTOP suspends a process and SIGCONT resumes it; neither is used by default with 'kill'.

  2. Bringing Background Processes to Foreground

    If a process was started in the background with 'u0026', which command brings its most recent job to the foreground?

    1. jobs
    2. bg
    3. fg
    4. ps

    Explanation: The 'fg' command brings the most recent background job into the foreground, allowing user interaction. 'bg' resumes a stopped job in the background but does not bring it to the foreground. 'jobs' lists active jobs, and 'ps' shows process status, but neither changes process states.

  3. Stoppage Signal with Keyboard Shortcut

    Which keyboard shortcut sends the SIGTSTP signal to a running foreground process to pause it?

    1. Ctrl+S
    2. Ctrl+D
    3. Ctrl+C
    4. Ctrl+Z

    Explanation: Pressing Ctrl+Z in a terminal sends the SIGTSTP signal, suspending the current foreground process. Ctrl+C sends SIGINT to interrupt a process, while Ctrl+D logs out of the terminal or sends EOF. Ctrl+S controls terminal flow but does not pause processes.

  4. Process Listing Command

    What command provides a real-time list of active processes and their statuses?

    1. grep
    2. ls
    3. sudo
    4. top

    Explanation: 'top' displays a dynamic, real-time view of currently running processes and their statuses. 'grep' searches for patterns in text, 'ls' lists directory contents, and 'sudo' executes commands with superuser privileges, but none show real-time process information.

  5. Unstoppable Signal

    Which of the following signals cannot be caught, blocked, or ignored by a process?

    1. SIGTERM
    2. SIGKILL
    3. SIGINT
    4. SIGUSR1

    Explanation: SIGKILL immediately terminates a process and cannot be intercepted, handled, or blocked. SIGUSR1, SIGINT, and SIGTERM can be handled by processes, allowing them to perform cleanup or ignore the signal in some cases.

  6. Sending Custom Signals

    How can you send the SIGUSR1 signal to a process with PID 5432 from the command line?

    1. kill 5432
    2. kill -USR1 5432
    3. kill -HUP 5432
    4. kill -9 5432

    Explanation: 'kill -USR1 5432' sends the user-defined signal SIGUSR1 to process 5432. The basic 'kill 5432' sends SIGTERM. 'kill -9 5432' sends SIGKILL, and 'kill -HUP 5432' sends SIGHUP, none of which are SIGUSR1.

  7. Backgrounding a Suspended Process

    After suspending a process with Ctrl+Z, which command resumes it in the background?

    1. bg
    2. fg
    3. stop
    4. suspend

    Explanation: 'bg' resumes a suspended job in the background, so the shell remains available for other commands. 'fg' brings the job to the foreground. 'stop' is not used as a command for jobs, and 'suspend' stops a shell session, not a process.

  8. Ignoring Signals

    Which UNIX signal is typically ignored by default by most programs?

    1. SIGKILL
    2. SIGINT
    3. SIGCHLD
    4. SIGTERM

    Explanation: SIGCHLD is sent to a parent when a child process terminates, and is usually ignored unless the parent is programmed to handle it. SIGKILL forces termination and cannot be ignored. SIGTERM and SIGINT are processed and usually lead to termination unless explicitly handled.

  9. Process Identification

    What is the name of the unique integer number assigned to each process in Unix/Linux?

    1. GID
    2. PID
    3. UID
    4. SID

    Explanation: PID stands for Process ID, which uniquely identifies each running process. UID is the User ID, GID is the Group ID, and SID refers to Session ID, but only PID is assigned to processes.

  10. Monitoring a Specific Process

    If you want to continuously monitor the output of a process with PID 2222, which command would be most appropriate?

    1. echo 2222
    2. strace -p 2222
    3. chmod 2222
    4. ls -l

    Explanation: 'strace -p 2222' attaches to the running process and displays its system calls, allowing for real-time monitoring. 'ls -l' lists file details, 'echo 2222' prints the number, and 'chmod 2222' attempts to change file permissions, which are unrelated to process output monitoring.