[LUG.ro] manejar señales en bash

Horacio Castellini lugro@lugro.org.ar
Mon, 15 Mar 2004 09:22:22 -0300


On Saturday 13 March 2004 07:16, you wrote:
> Hola!
> Estoy aprendiendo a hacer scripts para el bash.
> Mi problema es que no se como manejar la señales SIGINT,y SIGQUIT
> (que es cuando presionan ctrl-c ¿no?)
> En man del bash no me dice mucho. Si alguno me recomienda algun link
> para leer o me tira un ejemplito, se lo agradecere.

hcaste@clara:~$ help trap
trap: trap [arg] [signal_spec ...] or trap -l
    The command ARG is to be read and executed when the shell receives
    signal(s) SIGNAL_SPEC.  If ARG is absent all specified signals are
    reset to their original values.  If ARG is the null string each
    SIGNAL_SPEC is ignored by the shell and by the commands it invokes.
    If a SIGNAL_SPEC is EXIT (0) the command ARG is executed on exit from
    the shell.  If a SIGNAL_SPEC is DEBUG, ARG is executed after every
    command.  If ARG is `-p' then the trap commands associated with
    each SIGNAL_SPEC are displayed.  If no arguments are supplied or if
    only `-p' is given, trap prints the list of commands associated with
    each signal number.  Each SIGNAL_SPEC is either a signal name in 
<signal.h>
    or a signal number.  `trap -l' prints a list of signal names and their
    corresponding numbers.  Note that a signal can be sent to the shell
    with "kill -signal $$".