1<!--$Id: appsignals.so,v 10.28 2002/02/23 20:05:24 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB Reference Guide: Signal handling</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<a name="2"><!--meow--></a> 12<table width="100%"><tr valign=top> 13<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Programmer Notes</dl></b></td> 14<td align=right><a href="../apprec/config.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../program/errorret.html"><img src="../../images/next.gif" alt="Next"></a> 15</td></tr></table> 16<p align=center><b>Signal handling</b></p> 17<p>When applications using Berkeley DB receive signals, it is important that they 18exit gracefully, discarding any Berkeley DB locks that they may hold. This is 19normally done by setting a flag when a signal arrives and then checking 20for that flag periodically within the application. Because Berkeley DB is not 21re-entrant, the signal handler should not attempt to release locks and/or 22close the database handles itself. Re-entering Berkeley DB is not guaranteed to 23work correctly, and the results are undefined.</p> 24<p>If an application exits holding a lock, the situation is no different 25than if the application crashed, and all applications participating in 26the database environment must be shut down, and then recovery must be 27performed. If this is not done, databases may be left in an 28inconsistent state, or locks the application held may cause unresolvable 29deadlocks inside the environment, causing applications to hang.</p> 30<p>Berkeley DB restarts all system calls interrupted by signals, that is, any 31underlying system calls that return failure with errno set to EINTR will 32be restarted rather than failing.</p> 33<table width="100%"><tr><td><br></td><td align=right><a href="../apprec/config.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../program/errorret.html"><img src="../../images/next.gif" alt="Next"></a> 34</td></tr></table> 35<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 36</body> 37</html> 38