Forcing cleanup code in shell scripts?
Josh ChaitinPollak
josh at offthehill.org
Thu Nov 3 12:43:27 EST 2005
Is it possible to trap Ctrl-C and run some cleanup code in a shell
script? How would I do that?
I've got this shell script for setting up a gentoo embedded
environment, and it mounts a few directories, then chroots. If it
runs successfully, it umounts when done, but if it fails, it doesn't
run the umounts. Then I fix whatever bug it was that caused it to
fail, and rm -rf that directory to start again from scratch. And that
deletes my /usr/portage tree, and I get pissed and waste time.
Any ideas?
More information about the Discuss
mailing list