OVH Cloud OVH Cloud

nice => renice / trap => retrap ?

1 réponse
Avatar
David LE BOURGEOIS
Bonjour,

A la manière de renice pour la commande nice, est-il possible de faire
un trap sur un process déjà existant ? Existe-t-il un "retrap" ?

De même, y a-t-il une solution identique pour le nohup ?

Merci d'avance,
David.

1 réponse

Avatar
Stephane CHAZELAS
Le Wed, 27 Aug 2003 19:17:06 +0200, David LE BOURGEOIS écrivait :
A la manière de renice pour la commande nice, est-il possible de faire
un trap sur un process déjà existant ? Existe-t-il un "retrap" ?

De même, y a-t-il une solution identique pour le nohup ?


Peut-etre à l'aide d'un debugger:

~$ gcc -o /tmp/a.so -x c -shared -fPIC /dev/fd/0 << EOF
heredoc> void myhandler(int s) {
heredoc> system("echo 'Ouch!'");
heredoc> }
heredoc> EOF
~$ xlogo &
[2] 1869
~$ gdb xlogo
[...]
(gdb) attach 1869
Attaching to program: /usr/X11R6/bin/xlogo, process 1869
[...]
0x403629e2 in select () from /lib/libc.so.6
(gdb) call dlopen("/tmp/a.so", 1)
$1 = 134577896
(gdb) call dlsym($1, "myhandler")
$2 = 1073846236
(gdb) call signal(1, $2)
$3 = 0
(gdb) detach
Detaching from program: /usr/X11R6/bin/xlogo, process 1869
(gdb) quit
~$ kill -1 1869
~$ Ouch! 19:57

--
Stéphane