python: Added documentation and an example on how to handle SIGCHLD.
[collectd.git] / contrib / python / getsigchld.py
diff --git a/contrib/python/getsigchld.py b/contrib/python/getsigchld.py
new file mode 100644 (file)
index 0000000..557adc0
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+###############################################################################
+#         WARNING! Importing this script will break the exec plugin!          #
+###############################################################################
+# Use this if you want to create new processes from your python scripts.      #
+# Normally you will get a OSError exception when the new process terminates   #
+# because collectd will ignore the SIGCHLD python is waiting for.             #
+# This script will restore the default SIGCHLD behavior so python scripts can #
+# create new processes without errors.                                        #
+###############################################################################
+#         WARNING! Importing this script will break the exec plugin!          #
+###############################################################################
+
+import signal
+import collectd
+
+def init():
+       signal.signal(signal.SIGCHLD, signal.SIG_DFL)
+
+collectd.register_init(init)