Skip to content

Process

GradedJestRisk edited this page Apr 27, 2024 · 7 revisions

Table of Contents

Process

Log

Log process calls

Start

Background/Foreground:

  • start process in background <COMMAND> &
  • bring process in foreground fg <PROCESS_ID>
Detach from shell
nohup $COMMAND . &>/dev/null &
Ignore signals:
  • make a process ignore SIGHUP signal nohup <COMMAND>
  • make a process ignore SIGHUP signal, and allow logout (redirect input to NULL, output and error to separate files) nohup <COMMAND> > <OUTPUT_FILE> 2> <ERROR_FILE> < /dev/null
  • make a process ignore SIGHUP signal, and allow logout (redirect input, output, error to NULL) nohup <COMMAND> >/dev/null 2>&1

Kill

List:

  • force, using process ID kill -9 <PID
  • using process name: pkill '<PROCESS_NAME'
  • interactive mode (fabulous kill): fkill install

Inter-process communication (IPC)

Signals

Basics

A signal is an asynchronous notification sent to a process or to a specific thread within the same process to notify it of an event. If the process has previously registered a signal handler, that routine is executed. Otherwise, the default signal handler is executed. Signals are similar to interrupts, the difference being that

  • interrupts are mediated by the processor and handled by the kernel
  • signals are mediated by the kernel (possibly via system calls) and handled by processes
WP

List

List:

  • Triggered by / Name / Code
  • a user wishes to interrupt the process (Ctrl-C) / INTerruption / SIGINT
  • ? wishes to terminate the process (Ctrl-C) / TERmination / SIGTERM (SIGINT is nearly identical to SIGTERM)
  • terminate immediately / KILL the process / SIGKILL (cannot be caught or ignored)
    1. Run parallel
https://linuxsimply.com/bash-scripting-tutorial/basics/executing/run-commands-in-parallel/

Wait for all processes to finish

sleep 5 & sleep 1 & wait
Clone this wiki locally