summaryrefslogtreecommitdiff
path: root/lib/fatal-signal.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-01-15 15:28:14 -0800
committerBen Pfaff <blp@nicira.com>2010-01-15 15:28:14 -0800
commite3830e909d210145cbe52a1da66058ebf2581fd6 (patch)
treec82e02c5f101f38df1c6f12b46cc5345c9db433d /lib/fatal-signal.h
parent4d12270a618bead742d4cabc50601e86fde83f64 (diff)
downloadopenvswitch-e3830e909d210145cbe52a1da66058ebf2581fd6.tar.gz
fatal-signal: After fork, clear hooks instead of disabling them.
Until now, fatal_signal_fork() has simply disabled all the fatal signal callback hooks. This worked fine, because a daemon process forked only once and the parent didn't do much before it exited. But upcoming commits will introduce a --monitor option, which requires processes to fork multiple times. Sometimes the parent process will fork, then run for a while, then fork again. It's not good to disable the hooks in the child process in such a case, because that prevents e.g. pidfiles from being removed at the child's exit. So this commit changes the semantics of fatal_signal_fork() to just clearing out hooks. After hooks are cleared, new hooks can be added and will be executed on process termination in the usual way. This commit also introduces a cancellation callback function so that a canceled hook can free resources.
Diffstat (limited to 'lib/fatal-signal.h')
-rw-r--r--lib/fatal-signal.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/fatal-signal.h b/lib/fatal-signal.h
index a84d5fd71..94a1f1fb6 100644
--- a/lib/fatal-signal.h
+++ b/lib/fatal-signal.h
@@ -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.
@@ -20,7 +20,9 @@
#include <stdbool.h>
/* Basic interface. */
-void fatal_signal_add_hook(void (*)(void *aux), void *aux, bool run_at_exit);
+void fatal_signal_add_hook(void (*hook_cb)(void *aux),
+ void (*cancel_cb)(void *aux), void *aux,
+ bool run_at_exit);
void fatal_signal_fork(void);
void fatal_signal_run(void);
void fatal_signal_wait(void);