Lancement sur processus actifs :
$ ./repeter &
[1] 4099
Bonjour
$ gdb
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
...
(gdb) attach 4099
Attaching to process 4099
...
0xb77cd424 in __kernel_vsyscall ()
(gdb) list
1 #include <stdio.h>
2 #include <unistd.h>
3 int main(void){
4 while(1){ sleep(5); printf("Bonjour\n"); }
5 return 0;
6 }
(gdb) where
#0 0xb77cd424 in __kernel_vsyscall ()
#1 0xb76f5300 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
#2 0xb76f5150 in __sleep (seconds=0) at ../sysdeps/unix/sysv/linux/sleep.c:138
#3 0x08048461 in main () at repeter.c:4
(gdb) break 4
Breakpoint 1 at 0x8048455: file repeter.c, line 4.
(gdb) c
Continuing.
Bonjour
Breakpoint 1, main () at repeter.c:4
4 while(1){ sleep(5); printf("Bonjour\n"); }
(gdb) c
Continuing.
Bonjour
Breakpoint 1, main () at repeter.c:4
4 while(1){ sleep(5); printf("Bonjour\n"); }
(gdb) detach
Detaching from program: ./repeter, process 4099
(gdb) quit
$ pidof repeter
4099
$ lsof -p 4099
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
repeter 4099 pifou cwd DIR 8,17 4096 414993 /home/pifou/Exercices/Debug
repeter 4099 pifou rtd DIR 8,17 4096 2 /
repeter 4099 pifou txt REG 8,17 5888 399080 /home/pifou/Exercices/Debug/repeter
repeter 4099 pifou mem REG 8,17 1437864 524645 /lib/i386-linux-gnu/i686/cmov/libc-2.13.so
repeter 4099 pifou mem REG 8,17 117960 525200 /lib/i386-linux-gnu/ld-2.13.so
repeter 4099 pifou 0u CHR 136,0 0t0 3 /dev/pts/0
repeter 4099 pifou 1u CHR 136,0 0t0 3 /dev/pts/0
repeter 4099 pifou 2u CHR 136,0 0t0 3 /dev/pts/0
$ strace -p 4099
Process 4099 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>) = 0
write(1, "Bonjour\n", 8) = 8
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({5, 0}, 0xbfa2bdc4) = 0