64 lines
2.1 KiB
EmacsLisp
64 lines
2.1 KiB
EmacsLisp
;;; 70-process-management-lesson.el --- process-management-lesson
|
|
|
|
(defun process-management-lesson ()
|
|
"Linux+ lesson for process management and signals."
|
|
(interactive)
|
|
(delete-other-windows)
|
|
(let ((buf (get-buffer-create "*Process Management Lesson*"))
|
|
(shell (or shell-file-name (getenv "SHELL") "/bin/sh")))
|
|
(switch-to-buffer buf)
|
|
(read-only-mode -1)
|
|
(erase-buffer)
|
|
(insert
|
|
"Linux+ Lesson: Process Management and Signals\n"
|
|
"============================================\n\n"
|
|
"Concepts:\n"
|
|
"- ps shows processes\n"
|
|
"- top shows live processes\n"
|
|
"- kill sends signals to processes\n"
|
|
"- pkill kills by process name\n"
|
|
"- jobs shows shell background jobs\n\n"
|
|
"Important signals:\n"
|
|
" SIGTERM = 15 = graceful termination\n"
|
|
" SIGKILL = 9 = forced termination\n\n"
|
|
"Hands-on tasks:\n\n"
|
|
"1. View running processes:\n"
|
|
" ps aux | less\n\n"
|
|
"2. View live processes:\n"
|
|
" top\n"
|
|
" Press q to quit.\n\n"
|
|
"3. Start a background process:\n"
|
|
" sleep 300 &\n\n"
|
|
"4. View background jobs:\n"
|
|
" jobs\n\n"
|
|
"5. Find the sleep process:\n"
|
|
" ps aux | grep sleep\n\n"
|
|
"6. Kill the process gracefully:\n"
|
|
" kill PID\n\n"
|
|
"7. Start another sleep process:\n"
|
|
" sleep 300 &\n\n"
|
|
"8. Kill it by name:\n"
|
|
" pkill sleep\n\n"
|
|
"9. Start another sleep process:\n"
|
|
" sleep 300 &\n\n"
|
|
"10. Kill with SIGKILL:\n"
|
|
" kill -9 PID\n\n"
|
|
"Linux+ exam traps:\n"
|
|
"- kill sends signals, it does NOT always mean SIGKILL\n"
|
|
"- kill default signal is SIGTERM (15)\n"
|
|
"- pkill works by process name\n"
|
|
"- ps aux is VERY important\n\n"
|
|
"When finished, run:\n"
|
|
" M-x process-management-quiz\n")
|
|
(goto-char (point-min))
|
|
(view-mode 1)
|
|
(split-window-below)
|
|
(other-window 1)
|
|
(let ((term (get-buffer "*term*")))
|
|
(if (buffer-live-p term)
|
|
(switch-to-buffer term)
|
|
(ansi-term shell "term")))
|
|
(other-window -1)))
|
|
|
|
;;; 70-process-management-lesson.el ends here
|