[Rpm-maint] [rpm-software-management/rpm] RPM must kill all childs on exit (from section?) (#134)

Igor Gnatenko notifications at github.com
Sat Jan 28 08:27:37 UTC 2017


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 `./hang &` from `%check`.

I think @voxik has some real example in mongodb build while I have only dummy one:

hang.c:
```c
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
 
volatile sig_atomic_t done = 0;
 
static void
term (int signum)
{
  ;
  //done = 1;
}
 
int
main (int   argc,
      char *argv[])
{
  struct sigaction action;
  memset (&action, 0, sizeof (struct sigaction));
  action.sa_handler = term;
  sigaction (SIGTERM, &action, NULL);
                         
  int loop = 0;             
  while (!done)                 
    {                                       
      int t = sleep (3);                                    
      /* sleep returns the number of seconds left if interrupted */
      while (t > 0)                                                 
        {                                                                           
          printf ("Loop run was interrupted with %d "                                                   
                  "sec to go, finishing...\n", t);                                                                                         
          t = sleep(t);
        }                                                                                                                   
      printf("Finished loop run %d.\n", loop++);                            
    }                                                                           
                                 
  printf("done.\n");                
  return 0;                             
}
```

hang.spec:
```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
```

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.
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/134
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20170128/c60bf7e1/attachment.html>


More information about the Rpm-maint mailing list