compsci-missing_semester_2020/_subsections/lesson-05.org
2025-06-17 06:06:01 +03:00

3.8 KiB

Lesson 05 | Command line Environment

notes

topics

  • job control
  • terminal multiplexers
  • dot files / how to configure
  • work with remote machines

job control

sleep

  • puts process to sleep for a specified amount of time
  • exit by typing Ctrl-C

Ctrl-C

  • sends SIGINT - signal interrupt
  • man signal will show the list of signals

signals

SIGQUIT
signal sent when we want to quit
SIGTERM
similar to quit but not in term
SIGHUP
when we have processes running but still want to close

pausing

SIGSTOP
pause execution of program
SIGCONT
continue program

python library

  • use import signal
import signal
def handler(signum, frame):
    printf("signal received")

signal.signal(signal.SIGINT, handler)
  • the above would catch a Ctrl-C and run it through handler
  • you use this by catching a Ctrl-C and running any saves or cleanup before exiting

nohup and jobs

  • allows for a process to continue livign when the terminal is killed

example

  • sleep put the process to sleep
  • '&' puts the process in the background

    • wont take over the process
nohup sleep 2000 & python somprog.py

jobs

  • jobs

will show the suspended and running processes in background

  • how to restart a suspended process

    • type 'jobs' to see what there is in this terminal
    • the find the jobs number, ie [1] or [2]
    • use the 'bg' command

      bg %1

kill command