LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/io/nix - process_signal.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 13 18 72.2 %
Date: 2026-08-24 02:06:43 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2019 Juniper Networks, Inc. All rights reserved.
       3             : //
       4             : 
       5             : #include <sys/wait.h>
       6             : #include <boost/system/error_code.hpp>
       7             : 
       8             : #include <io/process_signal.h>
       9             : 
      10             : namespace process {
      11             : 
      12         217 : boost::system::error_code Signal::InitializeSigChild() {
      13         217 :     boost::system::error_code ec;
      14             : 
      15         217 :     if (!sigchld_callbacks_.empty() || always_handle_sigchild_) {
      16         171 :         ec = AddSignal(SIGCHLD);
      17             :     }
      18             : 
      19         217 :     return ec;
      20             : }
      21             : 
      22           0 : void Signal::RegisterHandler(SignalChildHandler handler) {
      23           0 :     if (sigchld_callbacks_.empty()) {
      24             :         // Add signal first
      25           0 :         AddSignal(SIGCHLD);
      26             :     }
      27           0 :     sigchld_callbacks_.push_back(handler);
      28           0 : }
      29             : 
      30         134 : bool Signal::HandleSigOsSpecific(const boost::system::error_code& error,
      31             :                                  int sig) {
      32         134 :     if (sig != SIGCHLD) {
      33          46 :         return false;
      34             :     }
      35             : 
      36          88 :     int status = 0;
      37          88 :     pid_t pid = 0;
      38             : 
      39         162 :     while ((pid = WaitPid(-1, &status, WNOHANG)) > 0) {
      40          74 :         NotifySigChld(error, sig, pid, status);
      41             :     }
      42             : 
      43          88 :     return true;
      44             : }
      45             : 
      46             : } // namespace process

Generated by: LCOV version 1.14