El mail inicial era mio, y con la urgencia que tenia de usar esos conocimientos, busque en el Web informacion ( no tengo instalada la pagina man del comando trap en mi sistema, y encontre la siguiente página: <<node41>> Espero que sirva de ayuda como me sirvio a mi. Saludos Gustavo ------------------------------ > En un reciente mensaje, he leido lo de poner traps a la ejecución de un > programa para no conseguir acceso a una shell... ¿alguien es tan amable de > explicarme qué es ésto, cómo funciona, con qué lenguajes puedo hacerlo, y > algún ejemplillo? >Title: trap: Trap signals
Next: Tips Using Shell Commands Up: Programming the Shell Previous: set: Change Command-line Parameters
trap: Trap signalsProcesses may be sent signals using either the kill command, or a control key combination such as CTRL-C. The interrupt signal (CTRL-C) usually kills the process. Table taken from [6, p. 883,] shows some of the signals used in Shell Programming.
The trap command typically appears as one of the first lines in the shell script. It contains the commands to be executed when a signal is detected as well as what signals to trap.
#!/bin/sh TMPFILE=/usr/tmp/junk.$$ trap 'rm -f $TMPFILE; exit 0' 1 2 15 . . . Upon receiving signals 1, 2 or 15, $TMPFILE would be deleted and the script would terminate the shell script normally. This shows how trap may be used to clean up before exiting.
#!/bin/sh TMPFILE=/usr/tmp/junk.$$ trap '' 0 1 2 . . . The above example shows how trap may be used to ignore specific signals (0, 1 and 2). NOTE that when the signal is received, the command currently being executed is interrupted, and execution flow continues at the next line of the script.
Claude Cantin Sun Apr 11 02:10:52 EDT 1999 |