rconn: New function rconn_get_last_error().
[sliver-openvswitch.git] / lib / fatal-signal.c
index d8862bb..9aa50e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -60,7 +60,11 @@ static void call_hooks(int sig_nr);
 
 /* Registers 'hook' to be called when a process termination signal is raised.
  * If 'run_at_exit' is true, 'hook' is also called during normal process
- * termination, e.g. when exit() is called or when main() returns. */
+ * termination, e.g. when exit() is called or when main() returns.
+ *
+ * 'func' will be invoked from an asynchronous signal handler, so it must be
+ * written appropriately.  For example, it must not call most C library
+ * functions, including malloc() or free(). */
 void
 fatal_signal_add_hook(void (*func)(void *aux), void *aux, bool run_at_exit)
 {
@@ -223,11 +227,17 @@ fatal_signal_unlink_file_now(const char *file)
 }
 
 static void
-unlink_files(void *aux UNUSED)
+unlink_files(void *aux OVS_UNUSED)
 {
     do_unlink_files(); 
 }
 
+/* This is a fatal_signal_add_hook() callback (via unlink_files()).  It will be
+ * invoked from an asynchronous signal handler, so it cannot call most C
+ * library functions (unlink() is an explicit exception, see
+ * http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html).
+ * That includes free(), so it doesn't try to free the 'files' data
+ * structure. */
 static void
 do_unlink_files(void)
 {