Hallo, Am Sam, 06 Mär 2010, Thomas Moritz schrieb:
Am Samstag, 6. März 2010 20:14:31 schrieb David Haller: Hallo David,
lockfile="/dev/shm/myscript.lock"
trap "rm -f $lockfile" SIGKILL
Nicht portabel.
Nicht moeglich!
Das bezog sich auf die Verwendung der "SIG" Prefix bei angabe der
Signale, die das 'trap' abfangen soll.
http://www.opengroup.org/onlinepubs/7990989775/xcu/chap2.html#tag_001_014_01...
====
The condition can be EXIT, 0 (equivalent to EXIT) or a signal
specified using a symbolic name, without the SIG prefix, as listed in
^^^^^^^^^^^^^^^^^^^^^^
the tables of signal names in the XSH specification under
# es hätte wie folgt lauten müssen (9 = SIGKILL): trap "rm -f $lockfile" 9
Das bekommt man aber nicht per 'killall script'. UND ES KANN EH NICHT ABGEFANGEN WERDEN!
s.o.
s.o. Erst hier geh ich auf's "KILL" ein ;)
trap "rm -f '$lockfile'" EXIT TERM INT HUP
"EXIT" ist das gesuchte, das gibt's beim regulären Beenden (z.B. durch 'exit 0' im script, oder auch wenn das Script per kill/killall mit SIGTERM (15) beendet wird.
Man - David, warum musst Du immer so lange pennen? Jetzt kann ich meine Aenderungen alle wieder zurueckschreiben und doch die lock-Files beibehalten :-)
Tja nu. Du hättest auch in man bash nach der Doku zu 'trap' suchen können. ;) ==== man bash ==== SHELL BUILTIN COMMANDS [..] trap [-lp] [arg] [sigspec ...] [..] signal number. If a sigspec is EXIT (0) the com mand arg is executed on exit from the shell. ==== Und da sich bei SIGTERM (15) das Script regulär beendet wird AFAIK auch ein trap auf EXIT ausgeführt. -dnh -- "Gott wollte angeben, als er dich erschaffen hat." -- "Jake" zu "Anna" in "Glauben ist alles" -- To unsubscribe, e-mail: opensuse-programming-de+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming-de+help@opensuse.org