control: Dump flight recorder on signal SIGUSR1

Add a SIGUSR1 handler to dump the flight recorder.

It uses the sdventplus sd_event_add_defer wrapper to do the dump when
the code gets back to the event loop so it doesn't spend the time doing
it inside the signal handler itself.

The flight recorder can now be dumped with:
    kill -USR1 $(pidof phosphor-fan-control)
    or
    systemctl kill -s USR1 phosphor-fan-control@0

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I46e45cb7a5e42ea4d217f63a8e14b6ef02ed8c22
diff --git a/control/main.cpp b/control/main.cpp
index 81c368b..dcd4679 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -83,6 +83,13 @@
             std::bind(&json::Manager::sighupHandler, &manager,
                       std::placeholders::_1, std::placeholders::_2));
 
+        // Enable SIGUSR1 handling to dump the flight recorder
+        stdplus::signal::block(SIGUSR1);
+        sdeventplus::source::Signal sigUsr1(
+            event, SIGUSR1,
+            std::bind(&json::Manager::sigUsr1Handler, &manager,
+                      std::placeholders::_1, std::placeholders::_2));
+
         phosphor::fan::util::SDBusPlus::getBus().request_name(CONTROL_BUSNAME);
 #else
         Manager manager(phosphor::fan::util::SDBusPlus::getBus(), event, mode);