]> sourceware.org Git - systemtap.git/commitdiff
PR19873: staprun -o BADFILE -c CMD cleanup
authorFrank Ch. Eigler <fche@redhat.com>
Sun, 27 Mar 2016 18:45:01 +0000 (14:45 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Sun, 27 Mar 2016 18:45:57 +0000 (14:45 -0400)
* staprun/mainloop.c (start_cmd): Close fd >= 3 to ensure no dangling
  reference to the stap module /.cmd file.  Set an alarm timeout, in
  case the parent process goes away and forgets to send us our SIGUSR
  to exec the CMD.

staprun/mainloop.c

index 65321d57a4008ab7f759be5d7385f1242d9cdc2f..82c0c74fcf0c71db19a60d81353eae3d8db32396 100644 (file)
@@ -214,6 +214,10 @@ void start_cmd(void)
     a.sa_handler = SIG_DFL;
     sigaction(SIGINT, &a, NULL);
 
+    /* Close any FDs we still hold, similarly as though this were
+       a program being spawned due to an system("") tapset function. */
+    closefrom(3);
+    
     /* We could call closefrom() here, to make sure we don't leak any
      * fds to the target, but it really isn't needed here since
      * close-on-exec should catch everything. We don't have the
@@ -257,6 +261,8 @@ void start_cmd(void)
    approximation, we just wait here for a signal from the parent. */
 
     dbug(1, "blocking briefly\n");
+    alarm(60); /* but not indefinitely */
+    
 #if WORKAROUND_BZ467568
     {
       /* Wait for the SIGUSR1 */
This page took 0.031054 seconds and 5 git commands to generate.