Fix Python plugins launching external processes

Without this change, Python plugins running external processes never
get the return code. See the collectd code [1] for the details.

[1] https://github.com/collectd/collectd/blob/master/contrib/python/getsigchld.py
diff --git a/collectd/files/plugin/collectd_apache_check.py b/collectd/files/plugin/collectd_apache_check.py
index 63ef855..790a60f 100644
--- a/collectd/files/plugin/collectd_apache_check.py
+++ b/collectd/files/plugin/collectd_apache_check.py
@@ -50,10 +50,6 @@
 plugin = ApacheCheckPlugin(collectd)
 
 
-def init_callback():
-    plugin.restore_sigchld()
-
-
 def config_callback(conf):
     plugin.config_callback(conf)
 
@@ -61,6 +57,5 @@
 def read_callback():
     plugin.read_callback()
 
-collectd.register_init(init_callback)
 collectd.register_config(config_callback)
 collectd.register_read(read_callback)
diff --git a/collectd/files/plugin/collectd_base.py b/collectd/files/plugin/collectd_base.py
index f042628..28cea12 100644
--- a/collectd/files/plugin/collectd_base.py
+++ b/collectd/files/plugin/collectd_base.py
@@ -17,7 +17,6 @@
 import json
 import signal
 import subprocess
-import sys
 import time
 import traceback
 
@@ -169,8 +168,8 @@
 
             ("foobar\n", "")
 
-            None if the command couldn't be executed or returned a non-zero
-            status code
+            (None, None) if the command couldn't be executed or returned a
+            non-zero status code
         """
         start_time = time.time()
         try:
@@ -186,14 +185,14 @@
         except Exception as e:
             self.logger.error("Cannot execute command '%s': %s : %s" %
                               (cmd, str(e), traceback.format_exc()))
-            return None
+            return (None, None)
 
         returncode = proc.returncode
 
         if returncode != 0:
             self.logger.error("Command '%s' failed (return code %d): %s" %
                               (cmd, returncode, stderr))
-            return None
+            return (None, None)
         if self.debug:
             elapsedtime = time.time() - start_time
             self.logger.info("Command '%s' returned %s in %0.3fs" %
@@ -222,18 +221,16 @@
 
     @staticmethod
     def restore_sigchld():
-        """Restores the SIGCHLD handler for Python <= v2.6.
+        """Restores the SIGCHLD handler.
 
         This should be provided to collectd as the init callback by plugins
-        that execute external programs.
+        that execute external programs and want to check the return code.
 
         Note that it will BREAK the exec plugin!!!
 
-        See https://github.com/deniszh/collectd-iostat-python/issues/2 for
-        details.
+        See contrib/python/getsigchld.py in the collectd project for details.
         """
-        if sys.version_info[0] == 2 and sys.version_info[1] <= 6:
-            signal.signal(signal.SIGCHLD, signal.SIG_DFL)
+        signal.signal(signal.SIGCHLD, signal.SIG_DFL)
 
     def notification_callback(self, notification):
         if not self.depends_on_resource:
diff --git a/collectd/files/plugin/collectd_libvirt_check.py b/collectd/files/plugin/collectd_libvirt_check.py
index 4660609..d0df216 100644
--- a/collectd/files/plugin/collectd_libvirt_check.py
+++ b/collectd/files/plugin/collectd_libvirt_check.py
@@ -49,10 +49,6 @@
 plugin = LibvirtCheckPlugin(collectd)
 
 
-def init_callback():
-    plugin.restore_sigchld()
-
-
 def config_callback(conf):
     plugin.config_callback(conf)
 
@@ -60,6 +56,5 @@
 def read_callback():
     plugin.read_callback()
 
-collectd.register_init(init_callback)
 collectd.register_config(config_callback)
 collectd.register_read(read_callback)
diff --git a/collectd/files/plugin/collectd_memcached_check.py b/collectd/files/plugin/collectd_memcached_check.py
index fb44aeb..5d0dd26 100644
--- a/collectd/files/plugin/collectd_memcached_check.py
+++ b/collectd/files/plugin/collectd_memcached_check.py
@@ -60,10 +60,6 @@
 plugin = MemcachedCheckPlugin(collectd)
 
 
-def init_callback():
-    plugin.restore_sigchld()
-
-
 def config_callback(conf):
     plugin.config_callback(conf)
 
@@ -71,6 +67,5 @@
 def read_callback():
     plugin.read_callback()
 
-collectd.register_init(init_callback)
 collectd.register_config(config_callback)
 collectd.register_read(read_callback)
diff --git a/collectd/files/plugin/collectd_mysql_check.py b/collectd/files/plugin/collectd_mysql_check.py
index a42414c..3f59896 100644
--- a/collectd/files/plugin/collectd_mysql_check.py
+++ b/collectd/files/plugin/collectd_mysql_check.py
@@ -103,10 +103,6 @@
 plugin = MySQLCheckPlugin(collectd)
 
 
-def init_callback():
-    plugin.restore_sigchld()
-
-
 def config_callback(conf):
     plugin.config_callback(conf)
 
@@ -114,6 +110,5 @@
 def read_callback():
     plugin.read_callback()
 
-collectd.register_init(init_callback)
 collectd.register_config(config_callback)
 collectd.register_read(read_callback)
diff --git a/collectd/files/plugin/collectd_vrrp.py b/collectd/files/plugin/collectd_vrrp.py
index ae873ff..b020ec2 100644
--- a/collectd/files/plugin/collectd_vrrp.py
+++ b/collectd/files/plugin/collectd_vrrp.py
@@ -73,10 +73,6 @@
 plugin = VrrpPlugin(collectd)
 
 
-def init_callback():
-    plugin.restore_sigchld()
-
-
 def config_callback(conf):
     plugin.config_callback(conf)
 
@@ -84,6 +80,5 @@
 def read_callback():
     plugin.read_callback()
 
-collectd.register_init(init_callback)
 collectd.register_config(config_callback)
 collectd.register_read(read_callback)
diff --git a/collectd/files/plugin/elasticsearch_cluster.py b/collectd/files/plugin/elasticsearch_cluster.py
index f60c1bc..e08d08a 100644
--- a/collectd/files/plugin/elasticsearch_cluster.py
+++ b/collectd/files/plugin/elasticsearch_cluster.py
@@ -109,10 +109,6 @@
 plugin = ElasticsearchClusterHealthPlugin(collectd, 'elasticsearch')
 
 
-def init_callback():
-    plugin.restore_sigchld()
-
-
 def config_callback(conf):
     plugin.config_callback(conf)
 
@@ -120,6 +116,5 @@
 def read_callback():
     plugin.read_callback()
 
-collectd.register_init(init_callback)
 collectd.register_config(config_callback)
 collectd.register_read(read_callback)
diff --git a/collectd/files/plugin/haproxy.py b/collectd/files/plugin/haproxy.py
index 17514e2..27b5604 100644
--- a/collectd/files/plugin/haproxy.py
+++ b/collectd/files/plugin/haproxy.py
@@ -291,10 +291,6 @@
 plugin = HAProxyPlugin(collectd)
 
 
-def init_callback():
-    plugin.restore_sigchld()
-
-
 def config_callback(conf):
     plugin.config_callback(conf)
 
@@ -302,6 +298,5 @@
 def read_callback():
     plugin.read_callback()
 
-collectd.register_init(init_callback)
 collectd.register_config(config_callback)
 collectd.register_read(read_callback)
diff --git a/collectd/files/plugin/influxdb.py b/collectd/files/plugin/influxdb.py
index 43cd82d..4b7426b 100644
--- a/collectd/files/plugin/influxdb.py
+++ b/collectd/files/plugin/influxdb.py
@@ -129,10 +129,6 @@
 plugin = InfluxDBClusterPlugin(collectd)
 
 
-def init_callback():
-    plugin.restore_sigchld()
-
-
 def config_callback(conf):
     plugin.config_callback(conf)
 
@@ -140,6 +136,5 @@
 def read_callback():
     plugin.read_callback()
 
-collectd.register_init(init_callback)
 collectd.register_config(config_callback)
 collectd.register_read(read_callback)