<p>Imagine, we have some stupid program which forks and doesn't exit until we send SIGTERM/SIGKILL, so build finishes, but process is still running. easy way to reproduce is just run <code>./hang &</code> from <code>%check</code>.</p>
<p>I think <a href="https://github.com/voxik" class="user-mention">@voxik</a> has some real example in mongodb build while I have only dummy one:</p>
<p>hang.c:</p>
<div class="highlight highlight-source-c"><pre>#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds"><</span>signal.h<span class="pl-pds">></span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds"><</span>stdio.h<span class="pl-pds">></span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds"><</span>string.h<span class="pl-pds">></span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds"><</span>unistd.h<span class="pl-pds">></span></span>
 
<span class="pl-k">volatile</span> <span class="pl-c1">sig_atomic_t</span> done = <span class="pl-c1">0</span>;
 
<span class="pl-k">static</span> <span class="pl-k">void</span>
<span class="pl-en">term</span> (<span class="pl-k">int</span> signum)
{
  ;
  <span class="pl-c"><span class="pl-c">//</span>done = 1;</span>
}
 
<span class="pl-k">int</span>
<span class="pl-en">main</span> (<span class="pl-k">int</span>   argc,
      <span class="pl-k">char</span> *argv[])
{
  <span class="pl-k">struct</span> <span class="pl-c1">sigaction</span> action;
  <span class="pl-c1">memset</span> (&action, <span class="pl-c1">0</span>, <span class="pl-k">sizeof</span> (<span class="pl-k">struct</span> <span class="pl-c1">sigaction</span>));
  action.<span class="pl-smi">sa_handler</span> = term;
  <span class="pl-c1">sigaction</span> (SIGTERM, &action, <span class="pl-c1">NULL</span>);
                         
  <span class="pl-k">int</span> loop = <span class="pl-c1">0</span>;             
  <span class="pl-k">while</span> (!done)                 
    {                                       
      <span class="pl-k">int</span> t = <span class="pl-c1">sleep</span> (<span class="pl-c1">3</span>);                                    
      <span class="pl-c"><span class="pl-c">/*</span> sleep returns the number of seconds left if interrupted <span class="pl-c">*/</span></span>
      <span class="pl-k">while</span> (t > <span class="pl-c1">0</span>)                                                 
        {                                                                           
          <span class="pl-c1">printf</span> (<span class="pl-s"><span class="pl-pds">"</span>Loop run was interrupted with <span class="pl-c1">%d</span> <span class="pl-pds">"</span></span>                                                   
                  <span class="pl-s"><span class="pl-pds">"</span>sec to go, finishing...<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>, t);                                                                                         
          t = <span class="pl-c1">sleep</span>(t);
        }                                                                                                                   
      <span class="pl-c1">printf</span>(<span class="pl-s"><span class="pl-pds">"</span>Finished loop run <span class="pl-c1">%d</span>.<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>, loop++);                            
    }                                                                           
                                 
  <span class="pl-c1">printf</span>(<span class="pl-s"><span class="pl-pds">"</span>done.<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>);                
  <span class="pl-k">return</span> <span class="pl-c1">0</span>;                             
}</pre></div>
<p>hang.spec:</p>
<pre><code class="language-rpmspec">Name:           hang
Version:        1
Release:        1%{?dist}
Summary:        Hanging build

License:        Public Domain
URL:            https://fedoraproject.org
Source0:        hang.c

BuildRequires:  gcc

%description
%{summary}.

%prep
%autosetup -c -T

%build
gcc %{__global_cflags} %{__global_ldflags} %{S:0} -o hang

%check
./hang &

%files

%changelog
</code></pre>
<p>I think easiest way is to catch all childs and send SIGKILL, but if we want to send SIGTERM, we will need to try sending SIGTERM, wait some time, check for still-alive processes and send SIGKILL.</p>
<pre><code></code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/rpm-software-management/rpm/issues/134">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ANb80xFJHyJDQLbsfuDL98vWYL74ebSSks5rWvv5gaJpZM4LwdAD">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ANb803G8VgEafl4pePQuzlvVCG3nmRtNks5rWvv5gaJpZM4LwdAD.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/rpm-software-management/rpm/issues/134"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/rpm-software-management/rpm","title":"rpm-software-management/rpm","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/rpm-software-management/rpm"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"RPM must kill all childs on exit (from section?) (#134)"}],"action":{"name":"View Issue","url":"https://github.com/rpm-software-management/rpm/issues/134"}}}</script>