diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-01-15T20·23+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-01-15T20·23+0000 |
commit | 447089a5f699f085661287dec4b3d88219f67068 (patch) | |
tree | e460c615181db3e6b6f8b48e4e934b372ecac043 /src/libstore/references.cc | |
parent | 08719c6c97e25fb362eeb7463d8b764ecefc53cb (diff) |
* Catch SIGINT to terminate cleanly when the user tries to interrupt
Nix. This is to prevent Berkeley DB from becoming wedged. Unfortunately it is not possible to throw C++ exceptions from a signal handler. In fact, you can't do much of anything except change variables of type `volatile sig_atomic_t'. So we set an interrupt flag in the signal handler and check it at various strategic locations in the code (by calling checkInterrupt()). Since this is unlikely to cover all cases (e.g., (semi-)infinite loops), sometimes SIGTERM may now be required to kill Nix.
Diffstat (limited to 'src/libstore/references.cc')
-rw-r--r-- | src/libstore/references.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libstore/references.cc b/src/libstore/references.cc index 2daf4d4f4d0a..9b20b980a1b2 100644 --- a/src/libstore/references.cc +++ b/src/libstore/references.cc @@ -17,6 +17,7 @@ static void search(const string & s, for (Strings::iterator i = ids.begin(); i != ids.end(); ) { + checkInterrupt(); if (s.find(*i) == string::npos) i++; else { @@ -31,6 +32,8 @@ static void search(const string & s, void checkPath(const string & path, Strings & ids, Strings & seen) { + checkInterrupt(); + struct stat st; if (lstat(path.c_str(), &st)) throw SysError(format("getting attributes of path `%1%'") % path); |