\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{TME520 (TME520)} \pdfinfo{ /Title (signaux-linux.pdf) /Creator (Cheatography) /Author (TME520 (TME520)) /Subject (Signaux Linux Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{E69812} \definecolor{LightBackground}{HTML}{FDF8F0} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Signaux Linux Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{TME520 (TME520)} via \textcolor{DarkBackground}{\uline{cheatography.com/20978/cs/3863/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}TME520 (TME520) \\ \uline{cheatography.com/tme520} \\ \uline{\seqsplit{tme520}.com} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 9th April, 2015.\\ Updated 19th October, 2017.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{3 règles}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{1. Seul {\emph{root}} peut manipuler les processus des autres utilisateurs et du système,} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{2. Un utilisateur ne peut agir que sur les processus qu'il possède,} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{3. {\emph{init}} (PID 1) est parfaitement insensible à tout ça.} \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{6.5626 cm} x{10.7074 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Un programme recevant un signal a 4 alternatives}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Ignorer}} & Le signal lui passe dessus comme un pet de coucou sur une toile cirée (c'est le cas quand le logiciel ne dispose d'aucun mécanisme approprié pour réagir ; {\emph{blame the developer !}}) \tn % Row Count 8 (+ 8) % Row 1 \SetRowColor{white} \{\{nobreak\}\}{\bf{Suspendre}} & L'exécution du processus est suspendue. Il reste en mémoire, attendant une action de son processus père, qui peut le stopper totalement ou poursuivre son déroulement sous d'autres conditions (en tâche de fond, par exemple). \tn % Row Count 18 (+ 10) % Row 2 \SetRowColor{LightBackground} {\bf{Quitter}} & Le signal provoque l'arrêt du processus. Dans certains cas, un fichier {\emph{core}} (comme dans {\emph{core dump}}) destiné à être exploité par un debugger est écrit sur un disque. \tn % Row Count 26 (+ 8) % Row 3 \SetRowColor{white} {\bf{Exécuter}} & Une fonction dédiée à la gestion du signal est exécutée, puis le logiciel reprend son cours normal. \tn % Row Count 31 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.9804 cm} x{8.2896 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{2 types de signaux}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Type}} & {\bf{Numéros}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\emph{Classique}} & 1-31 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\emph{Temps-réel}} & 32-64 \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Les signaux « temps-réel »}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Tout ce qui est au-delà de 31 correspond à des signaux dits « temps-réel » configurables comme on le veut. Leur nombre exact est défini par les macros SIGRTMIN et SIGRTMAX. Qu'est-ce qui différencie les signaux classiques des signaux TR ({\emph{RT}} pour {\emph{Real Time}} en Anglais) ? \newline % Row Count 6 (+ 6) Premièrement, au contraire de ce qui se passe pour un signal classique, aucune occurrence d'un signal TR ne se perd, même si elle vient en doublon ou plus. Toutes sont placées dans une file d'attente selon leur ordre de priorité (plus bas est le numéro du signal, plus haute est sa priorité). \newline % Row Count 13 (+ 7) Deuxièmement, il est possible de communiquer une valeur entière ou un pointeur en accompagnement d'un signal TR. \newline % Row Count 16 (+ 3) Troisièmement, si plusieurs signaux TR du même type sont envoyés à un processus, ils sont exécutés dans leur ordre d'arrivée. \newline % Row Count 19 (+ 3) Quatrièmement, les signaux TR ne sont jamais déclenchés par le kernel, mais par l'utilisateur. Ils sont, un peu à la manière de {\emph{SIGUSR1}} et {\emph{SIGUSR2}}, définis en fonction des besoins.% Row Count 23 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{1.687 cm} x{3.0366 cm} x{12.1464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Les signaux classiques}} \tn % Row 0 \SetRowColor{LightBackground} 1 & SIGHUP & Fin de connexion ({\emph{hang-up}}) du terminal de contrôle. Peut être envoyé manuellement à un daemon afin qu'il se réinitialise. \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} 2 & SIGINT & Interruption en provenance du clavier (Ctrl + C). Peut être ignoré, intercepté ou bloqué. Quitte proprement. \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} 3 & \seqsplit{SIGQUIT} & Interruption en provenance du clavier (Ctrl + \textbackslash{}). Même chose que SIGINT à cela près qu'un fichier core dump est généré. \tn % Row Count 14 (+ 5) % Row 3 \SetRowColor{white} 4 & SIGILL & Le programme a tenté d'exécuter une instruction invalide ou non-supportée par le microprocesseur / le coprocesseur arithmétique. \tn % Row Count 19 (+ 5) % Row 4 \SetRowColor{LightBackground} 5 & \seqsplit{SIGTRAP} & Utilisé pour indiquer à un programme en cours de {\emph{debug}} qu'un point d'arrêt a été atteint. \tn % Row Count 23 (+ 4) % Row 5 \SetRowColor{white} 6 & \seqsplit{SIGABRT} & Ce signal est émis lorsqu'un programme rencontre un problème forçant son arrêt. Génère un {\emph{core dump}}. \tn % Row Count 27 (+ 4) % Row 6 \SetRowColor{LightBackground} 7 & SIGBUS & Ce signal est émis lorsqu'un programme tente d'utiliser une adresse mémoire invalide (mauvais alignement, adresse impaire, adresse indisponible…). \tn % Row Count 33 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{1.687 cm} x{3.0366 cm} x{12.1464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Les signaux classiques (cont)}} \tn % Row 7 \SetRowColor{LightBackground} 8 & SIGFPE & Erreur arithmétique (division par zéro). Génère un {\emph{core dump}} et tombe raide mort. \tn % Row Count 4 (+ 4) % Row 8 \SetRowColor{white} 9 & \seqsplit{SIGKILL} & On signale au kernel qu'on veut stopper net un processus. Ne peut être ni ignoré, ni intercepté, ni bloqué. \tn % Row Count 9 (+ 5) % Row 9 \SetRowColor{LightBackground} 10 & \seqsplit{SIGUSR1} & Par défaut un logiciel recevant ce signal s'arrête, à moins que son programmeur n'ait prévu quelque chose d'autre (afficher des statistiques, écrire dans un fichier journal…). C'est en quelque sorte un signal personnalisable pouvant servir à déclencher ce qu'on veut. \tn % Row Count 20 (+ 11) % Row 10 \SetRowColor{white} 11 & \seqsplit{SIGSEGV} & Erreur de protection mémoire ({\emph{segmentation fault}}). Cela se produit quand un processus demande à écrire à une adresse ne figurant pas dans son espace d'adressage. \tn % Row Count 27 (+ 7) % Row 11 \SetRowColor{LightBackground} 12 & \seqsplit{SIGUSR2} & Idem SIGUSR1. \tn % Row Count 28 (+ 1) % Row 12 \SetRowColor{white} 13 & \seqsplit{SIGPIPE} & Le fameux {\emph{Broken pipe}}. Survient quand on envoie des données dans un tuyau ({\emph{pipe}}) alors que personne n'est à l'autre bout pour les récupérer. \tn % Row Count 34 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{1.687 cm} x{3.0366 cm} x{12.1464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Les signaux classiques (cont)}} \tn % Row 13 \SetRowColor{LightBackground} 14 & \seqsplit{SIGALRM} & Utilisé pour programmer des temporisations sur des opérations bloquantes ou susceptibles de l'être (lecture/écriture sur un volume réseau par exemple). \tn % Row Count 6 (+ 6) % Row 14 \SetRowColor{white} 15 & \seqsplit{SIGTERM} & Une invitation à quitter proprement est envoyée au processus. Peut être ignoré, intercepté ou bloqué. La différence avec SIGINT ? Aucune combinaison de touches ne permet de générer un SIGTERM. \tn % Row Count 14 (+ 8) % Row 15 \SetRowColor{LightBackground} 16 & \seqsplit{SIGSTKFLT} & Indique une erreur de pile. Normalement pas utilisé. Par défaut, provoque l'arrêt du programme. \tn % Row Count 18 (+ 4) % Row 16 \SetRowColor{white} 17 & \seqsplit{SIGCHLD} & Un des processus fils est mort ou a été arrêté. \tn % Row Count 20 (+ 2) % Row 17 \SetRowColor{LightBackground} 18 & \seqsplit{SIGCONT} & Redémarrage d'un processus temporairement arrêté. \tn % Row Count 22 (+ 2) % Row 18 \SetRowColor{white} 19 & \seqsplit{SIGSTOP} & Arrêt temporaire d'un processus (ne peut être ignoré). \tn % Row Count 25 (+ 3) % Row 19 \SetRowColor{LightBackground} 20 & \seqsplit{SIGTSTP} & Arrêt temporaire d'un processus (Ctrl + Z). Peut être ignoré. \tn % Row Count 28 (+ 3) % Row 20 \SetRowColor{white} 21 & \seqsplit{SIGTTIN} & Signal envoyé à un processus lorsqu'il tente de lire depuis son terminal alors qu'il est en tâche de fond (un processus en tâche de fond ne peut pas lire/écrire via un terminal). \tn % Row Count 35 (+ 7) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{1.687 cm} x{3.0366 cm} x{12.1464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Les signaux classiques (cont)}} \tn % Row 21 \SetRowColor{LightBackground} 22 & \seqsplit{SIGTTOU} & Signal envoyé à un processus lorsqu'il tente d'écrire sur son terminal alors qu'il est en tâche de fond (un processus en tâche de fond ne peut pas lire/écrire via un terminal). \tn % Row Count 7 (+ 7) % Row 22 \SetRowColor{white} 23 & SIGURG & Indique à un processus que des données dites « hors-bande » sont arrivées sur un socket TCP/IP. Les données « hors-bande » sont à un flux réseau ce que les caractères de contrôle sont à une chaîne de caractères. \tn % Row Count 16 (+ 9) % Row 23 \SetRowColor{LightBackground} 24 & \seqsplit{SIGXCPU} & Émis par le kernel quand un processus dépasse le temps d'utilisation CPU qui lui a été alloué. \tn % Row Count 20 (+ 4) % Row 24 \SetRowColor{white} 25 & \seqsplit{SIGXFSZ} & Émis par le kernel quand un processus tente de créer un fichier trop grand. \tn % Row Count 23 (+ 3) % Row 25 \SetRowColor{LightBackground} 26 & \seqsplit{SIGVTALRM} & Indique le déclenchement d'un timer virtuel. Comparable à une sonnerie de réveil pour processus. \tn % Row Count 27 (+ 4) % Row 26 \SetRowColor{white} 27 & \seqsplit{SIGPROF} & Indique le déclenchement d'un timer dit « de profiling ». On fait du {\emph{profiling}} sur un processus quand on veut en améliorer les performances. \tn % Row Count 33 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{1.687 cm} x{3.0366 cm} x{12.1464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Les signaux classiques (cont)}} \tn % Row 27 \SetRowColor{LightBackground} 28 & \seqsplit{SIGWINCH} & La fenêtre du terminal a été redimensionnée. \tn % Row Count 2 (+ 2) % Row 28 \SetRowColor{white} 29 & SIGIO & Ne pas confondre avec SIGIOT, l'équivalent sous UNIX System V du SIGABRT de Linux. Indique à un processus qu'il peut effectuer une opération d'entrée/sortie (I/O). \tn % Row Count 9 (+ 7) % Row 29 \SetRowColor{LightBackground} 30 & SIGPWR & Indique un problème d'alimentation. Utile notamment sur systèmes mobiles ou alimentés via un onduleur suite à une coupure du secteur. \tn % Row Count 14 (+ 5) % Row 30 \SetRowColor{white} 31 & SIGSYS & Le programme a tenté d'appeler une fonction système invalide. \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5915 cm} x{5.2297 cm} x{4.0488 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{5 exemples}} \tn % Row 0 \SetRowColor{LightBackground} Redémarrer un daemon & /bin/kill -SIGHUP PID & \seqsplit{/bin/kill} -1 PID \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Arrêter proprement un processus & /bin/kill -SIGTERM PID & \seqsplit{/bin/kill} -15 PID \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Arrêter brutalement un processus & /bin/kill -SIGKILL PID & \seqsplit{/bin/kill} -9 PID \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Mettre un processus en pause & /bin/kill -SIGSTOP PID & \seqsplit{/bin/kill} -19 PID \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Sortir un processus de pause & /bin/kill -SIGCONT PID & \seqsplit{/bin/kill} -18 PID \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \end{document}