Précédent   Forum des professionnels en informatique > Systèmes > Linux
Linux Forum d'entraide sur le système Linux. Avant de poster -> Tutoriels Linux, F.A.Q Linux
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 22/02/2011, 09h13   #1
Membre éprouvé
 
Avatar de ben.IT
 
Homme Benoît
Inscription : janvier 2009
Messages : 392
Détails du profil
Informations personnelles :
Nom : Homme Benoît
Âge : 24
Localisation : France, Puy de Dôme (Auvergne)

Informations forums :
Inscription : janvier 2009
Messages : 392
Points : 438
Points : 438
Par défaut Différence entre kill -9 et kill -15, choix de signal

Salut à tous,
je viens de tuer un processus récalcitrant avec kill -9, en cherchant un peu sur le net j'ai vu des gens qui utilisaient le signal 15, je suis allé chercher le man de signal et voici ce que j'ai trouvé sur les différents signaux.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
   Standard Signals
       Linux  supports  the  standard  signals listed below.  Several signal numbers are architecture-dependent, as indicated in the "Value" column.  (Where three values are
       given, the first one is usually valid for alpha and sparc, the middle one for ix86, ia64, ppc, s390, arm and sh, and the last one for mips.  A - denotes that a signal
       is absent on the corresponding architecture.)

       First the signals described in the original POSIX.1-1990 standard.

       Signal     Value     Action   Comment
       ----------------------------------------------------------------------
       SIGHUP        1       Term    Hangup detected on controlling terminal
                                     or death of controlling process
       SIGINT        2       Term    Interrupt from keyboard
       SIGQUIT       3       Core    Quit from keyboard
       SIGILL        4       Core    Illegal Instruction
       SIGABRT       6       Core    Abort signal from abort(3)
       SIGFPE        8       Core    Floating point exception
       SIGKILL       9       Term    Kill signal
       SIGSEGV      11       Core    Invalid memory reference
       SIGPIPE      13       Term    Broken pipe: write to pipe with no
                                     readers
       SIGALRM      14       Term    Timer signal from alarm(2)
       SIGTERM      15       Term    Termination signal
       SIGUSR1   30,10,16    Term    User-defined signal 1
       SIGUSR2   31,12,17    Term    User-defined signal 2
       SIGCHLD   20,17,18    Ign     Child stopped or terminated
       SIGCONT   19,18,25    Cont    Continue if stopped
       SIGSTOP   17,19,23    Stop    Stop process
       SIGTSTP   18,20,24    Stop    Stop typed at tty
       SIGTTIN   21,21,26    Stop    tty input for background process
       SIGTTOU   22,22,27    Stop    tty output for background process

       The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.

Quelle est la différence entre le signal 9 et le signal 15 ?
Lequel vaut il mieux utiliser ?


merci d'avance,
ben
__________________
Meet the free software gang
ben.IT est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/02/2011, 09h36   #2
Membre régulier
 
Inscription : décembre 2009
Messages : 97
Détails du profil
Informations forums :
Inscription : décembre 2009
Messages : 97
Points : 70
Points : 70
Le signal 15 est le signal 'normal' pour terminer un processus, celui ci peut néanmoins être ignoré par le processus en cas de problème par exemple.

Le signal 9 est un peu plus 'brutal', il ne peut être ignoré et terminera ton processus dans tous les cas.

slyz0r est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 22/02/2011, 10h56   #3
Membre Expert
 
Homme Alexis
Intégrateur d'Exploitation
Inscription : février 2003
Messages : 876
Détails du profil
Informations personnelles :
Nom : Homme Alexis
Âge : 32
Localisation : France

Informations professionnelles :
Activité : Intégrateur d'Exploitation
Secteur : Biens de consommation

Informations forums :
Inscription : février 2003
Messages : 876
Points : 1 619
Points : 1 619
Envoyer un message via ICQ à Alek-C Envoyer un message via Skype™ à Alek-C
Citation:
Envoyé par benilto Voir le message
...

Code :
1
2
3
4
5
6
   ...
       SIGKILL       9       Term    Kill signal
...
       SIGTERM      15       Term    Termination signal
...
       The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.
Comme indiqué dans ta citation et confirmé par slyz0r, SIGKILL ne peut pas être intercepté ni bloqué ni ignoré par ton process, donc en théorie, ça devrait permettre de tuer un process qui ne s'arrête pas avec un SIGTERM.

En général, tu envoies déjà un SIGTERM à ton process, s'il n'est pas complètement en vrac, et s'il est bien foutu, il devrait avoir une routine qui intercepte le SIGTERM et force sa fermeture "proprement" : terminaison des connexions réseaux, fermeture des descripteurs de fichiers, etc.

Si au bout d'un certain temps, ton process tourne toujours, c'est peut-être qu'il est trop dans les choux (voir c'est l'OS qui a du mal carrément), donc il ne te reste qu'à tenter un SIGKILL pour l'arrêter (ce qui ne marche malheureusement pas toujours non plus, mais le plus souvent, c'est radical )

Je t'invite à lire l'article Wikipedia correspondant et qui est plutôt bien fait !
Alek-C est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 22/02/2011, 11h48   #4
Membre éprouvé
 
Avatar de ben.IT
 
Homme Benoît
Inscription : janvier 2009
Messages : 392
Détails du profil
Informations personnelles :
Nom : Homme Benoît
Âge : 24
Localisation : France, Puy de Dôme (Auvergne)

Informations forums :
Inscription : janvier 2009
Messages : 392
Points : 438
Points : 438
ok,
le signal -9 est donc en cas de plantage/debugage pour mettre une balle dans la tête au prg récalcitrant, et le 15 est le signal de terminaison classique.
merci à vous 2,
ben
__________________
Meet the free software gang
ben.IT est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/02/2011, 13h47   #5
Membre éprouvé
 
Avatar de ben.IT
 
Homme Benoît
Inscription : janvier 2009
Messages : 392
Détails du profil
Informations personnelles :
Nom : Homme Benoît
Âge : 24
Localisation : France, Puy de Dôme (Auvergne)

Informations forums :
Inscription : janvier 2009
Messages : 392
Points : 438
Points : 438
Par défaut link to SIGKILL and SIGSTOP well explained

merci encore pour vos réponse,
j'ai trouvé un article intéressant à ce sujet ici : http://tldp.org/LDP/Bash-Beginners-G...ect_12_01.html

dont voici un extrait :
Citation:

SIGKILL and SIGSTOP can not be caught, blocked or ignored.

When killing a process or series of processes, it is common sense to start trying with the least dangerous signal, SIGTERM. That way, programs that care about an orderly shutdown get the chance to follow the procedures that they have been designed to execute when getting the SIGTERM signal, such as cleaning up and closing open files. If you send a SIGKILL to a process, you remove any chance for the process to do a tidy cleanup and shutdown, which might have unfortunate consequences.

But if a clean termination does not work, the INT orKILL signals might be the only way. For instance, when a process does not die using Ctrl+C, it is best to use the kill -9 on that process ID:
à bientôt,
ben
__________________
Meet the free software gang
ben.IT est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 11h09.


 
 
 
 
Partenaires

Hébergement Web