jeudi 16 février 2012

signaux et terminaux, stty

A la base, une simple question de la part d'une collègue : comment envoyer un SIGQUIT dans un terminal sous mac OS.
Une rapide recherche sur le net donne comme réponse "^\", contrairement à linux où c'est usuellement "^d" qui sert à cela.

Comment configurer cela, comment trouver cela ?


STTY(1)                          User Commands                         STTY(1)
NAME
       stty - change and print terminal line settings

SYNOPSIS
       stty [-F DEVICE | --file=DEVICE] [SETTING]...
       stty [-F DEVICE | --file=DEVICE] [-a|--all]
       stty [-F DEVICE | --file=DEVICE] [-g|--save]

DESCRIPTION
       Print or change terminal characteristics.

Qui chez moi par exemple (Ubuntu) me donne :
 
$ stty -a
speed 38400 baud; rows 40; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt 
Donc en fait "^d" envoie un "eof", pas un sig_quit...