[padb-devel] [padb commit] r38 - Use symbolic names rather than numbers when delivering

codesite-noreply at google.com codesite-noreply at google.com
Tue Jun 9 11:57:00 BST 2009


Author: apittman
Date: Tue Jun  9 03:55:34 2009
New Revision: 38

Modified:
    trunk/src/padb

Log:
Use symbolic names rather than numbers when delivering
a signal.  Fixes issue #1.


Modified: trunk/src/padb
==============================================================================
--- trunk/src/padb	(original)
+++ trunk/src/padb	Tue Jun  9 03:55:34 2009
@@ -201,6 +201,7 @@
  use Sys::Hostname;
  use File::Temp qw(tempfile);
  use MIME::Base64;
+use Config;

   
###############################################################################
  #
@@ -566,6 +567,10 @@
  my @config_options;
  my %ic_names;

+# Populated in the outer args section so that outer code
+# can access secondary comamnd line argunments by name.
+my %secondary_args;
+
  sub parse_args_outer {

      Getopt::Long::Configure("bundling");
@@ -627,6 +632,13 @@
          $have_allfns_option++;
      }

+    # Put the args in a hash so that they can be referenced by name.
+    if ( defined $allfns{$mode}{secondary} ) {
+        foreach my $sec ( @{ $allfns{$mode}{secondary} } ) {
+            $secondary_args{ $sec->{arg_long} } = $sec->{value};
+        }
+    }
+
      return $mode;
  }

@@ -3414,6 +3426,17 @@
          );
      }

+    # If delivering a signal check that it's valid.
+    if ( defined($mode) and ( $mode eq "kill" ) ) {
+        my $signal = $secondary_args{signal};
+        my %sig_names;
+        map { $sig_names{$_} = 1 } split( " ", $Config{"sig_name"} );
+
+        if ( not defined $sig_names{$signal} ) {
+            cmdline_error("$prog: Error: signal $signal is invalid\n");
+        }
+    }
+
      if ( $tree and !( ( defined $mode && $mode eq "stack" ) or $input_file  
) ) {
          cmdline_error("$prog: Error: --tree only works with  
--stack-trace\n");
      }
@@ -5652,6 +5675,7 @@

      $confInner{"mode"} = $mode;

+    # Put the args in a hash so that they can be referenced by name.
      if ( defined $allfns{$mode}{secondary} ) {
          foreach my $sec ( @{ $allfns{$mode}{secondary} } ) {
              $confInner{"args"}{ $sec->{arg_long} } = $sec->{value};
@@ -5785,8 +5809,8 @@
          'secondary' => [
              {
                  'arg_long' => 'signal',
-                'type'     => 'i',
-                'default'  => '15'
+                'type'     => 's',
+                'default'  => 'TERM'
              }
          ]
      };




More information about the padb-devel mailing list