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-03 02:19:58 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         218 : boost::system::error_code Signal::InitializeSigChild() {
      13         218 :     boost::system::error_code ec;
      14             : 
      15         218 :     if (!sigchld_callbacks_.empty() || always_handle_sigchild_) {
      16         172 :         ec = AddSignal(SIGCHLD);
      17             :     }
      18             : 
      19         218 :     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         175 : bool Signal::HandleSigOsSpecific(const boost::system::error_code& error,
      31             :                                  int sig) {
      32         175 :     if (sig != SIGCHLD) {
      33          46 :         return false;
      34             :     }
      35             : 
      36         129 :     int status = 0;
      37         129 :     pid_t pid = 0;
      38             : 
      39         245 :     while ((pid = WaitPid(-1, &status, WNOHANG)) > 0) {
      40         116 :         NotifySigChld(error, sig, pid, status);
      41             :     }
      42             : 
      43         129 :     return true;
      44             : }
      45             : 
      46             : } // namespace process

Generated by: LCOV version 1.14