Created
October 24, 2016 06:13
-
-
Save hacker65536/fdb262ec30a0b3fb41b41e65a84b79a9 to your computer and use it in GitHub Desktop.
trap test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -me | |
function exitf(){ | |
echo "catch exit" | |
} | |
function excep(){ | |
echo "catch exception" | |
} | |
# EXITシグナルをtrapして終了メッセージを指定する。 | |
trap exitf EXIT | |
# 他のシグナルもtrapしておく。 | |
trap excep 1 2 3 15 | |
# Ctrl+Cで終了するテストのためにsleepしておく。 | |
sleep 10 | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment