Open main menu

CDOT Wiki β

Changes

Tutorial8: Links / Process Management

143 bytes added, 13:37, 25 February 2021
INVESTIGATION 2: MANAGING PROCESSES
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">sleep 700</span><br><br>
# Notice that this process will run for '''700 seconds''', and is forcing the user to wait until this process finishes.<br>A process that is '''running in the terminal''' is referred to as a '''foreground process'''.<br><br>The Unix/Linux system is designed to allow users to send '''preemptive signals''' to manage those processes.<br><br>
# Press the following key combination to '''terminate''' the command running on the terminal: <span style="color:blue;font-family:courier;font-weight:bold">ctrl-c</span><br><br>You should notice that the process that was running in the foreground has been '''interrupted''' (i.e. terminated).<br>'''NOTE:''' The '''ctrl-c''' key combination sends '''SIGINT''' ('''Signal Interrupt''' - which is signal '''#2''') signal to terminate a process<br>that is running on the terminal(i.e. the '''foreground''').<br><br>
# Reissue the Linux command: <span style="color:blue;font-family:courier;font-weight:bold">sleep 700</span><br><br>
# Press the key combination: <span style="color:blue;font-family:courier;font-weight:bold">ctrl-z</span><br><br>
# Press the key combination: <span style="color:blue;font-family:courier;font-weight:bold">ctrl-c</span> to '''terminate''' the process running in the '''foreground'''.<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">sleep 500 & sleep 600 & sleep 700 &</span><br><br>
# Issue the '''jobs''' command. What do you notice?<br><br>In the jobs command output, jobs that display a plus sign ('''+''') indicates the '''most recent''' process<br>placed in to the background, and a minus sign ('''-''') indicates the '''second most recent''' process<br>placed into the background.<br><br>The '''kill''' command issued to terminate processes that are running in the '''foreground''' or '''background'''. Issuing the kill command <u>without</u> options would send the '''SIGTERM''' signal (eg. ''signal terminate'' - which is signal '''#15''').<br><br>
# Issue the following Linux command to '''terminate''' the '''first''' job running in the background:<br><span style="color:blue;font-family:courier;font-weight:bold">kill %1</span><br><br>'''NOTE:''' You can specify job number preceded by percent % with the<br>'''kill''', '''bg''', and '''fg''' commands to specify the processes' job number.<br><br>
# Issue the '''jobs''' command. What do you notice?<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">(sleep 400; sleep 500; sleep 600) &</span><br><br>
# Issue the '''jobs''' command. What do you notice?<br>You should notice all commands are run in a group as just one process.<br><br>
# Issue the following Linux command to terminate the first job:<br><span style="color:blue;font-family:courier;font-weight:bold">kill %1</span><br><br>NOTE: If issuing the kill command does not work, then you would need to send a STRONGER signal<br>to "'''kill'''" (not "''SIGTERM'' - which is signal ''#15''") the process. The '''SIGKILL''' signal (signal '''#9''')<br>would be required to do this by issuing the '''kill''' command with the option: '''-9'''.<br><br>By the way, the '''ctrl-c''' key combination sends the ''SIGINT'' (signal interupt - which is signal '''#2''')<br>to terminate processes running in the ''foreground''.<br><br>
# Issue the '''jobs''' command and make certain there are no processes that are running in the background.<br><br>Let's terminate our Matrix Bash shell process by using the '''kill''' command using that process' '''PID'''.<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">ps</span><br><br>
13,420
edits