Description:
The file mysql/mysql-test/lib/My/SafeProcess/safe_process.pl contains 2 numeric references (==9) to the SIGKILL signal. These should be symbolic references (=='KILL').
The reason for this report is that neither the C-99 nor the POSIX-2008 standards specify a binding between signal numbers and signal names; hence, this method of coding can cause issues on otherwise POSIX-compliant implementations that happen to use a different signal numbering scheme than Linux or Unix.
As far as I can tell, all other references to signals in the perl scripts have already been converted to symbolic references. These are the only remaining numeric references that I can find. I searched for 'kill' and '$SIG'.
Note: The behavior of "kill(0, ...)" is well-defined by the POSIX standard and should not be changed.
I ran across this issue in MySQL 5.1.48; I have just verified that it still exists in MySQL 5.6.2-m5.
I have submitted a SCA in the past; it should still be on file; if not, let me know and I will submit a new one.
How to repeat:
The error can be found by visually inspecting the perl scripts, looking at the first argument to the "kill" function, and for references to the $SIG vector. See the text below, under "Suggested fix", for an example of such references.
Suggested fix:
Index: trunk/2.0/mysql/mysql-test/lib/My/SafeProcess/safe_process.pl
===================================================================
--- trunk/2.0/mysql/mysql-test/lib/My/SafeProcess/safe_process.pl (revision 41)
+++ trunk/2.0/mysql/mysql-test/lib/My/SafeProcess/safe_process.pl (revision 42)
@@ -94,7 +94,7 @@
local $SIG{INT}= \&handle_signal;
local $SIG{CHLD}= sub {
message("Got signal @_");
- kill(9, -$child_pid);
+ kill('KILL', -$child_pid);
my $ret= waitpid($child_pid, 0);
if ($? & 127){
exit(65); # Killed by signal
@@ -134,7 +134,7 @@
# Use negative pid in order to kill the whole
# process group
#
-my $ret= kill(9, -$child_pid);
+my $ret= kill('KILL', -$child_pid);
message("Killed child: $child_pid, ret: $ret");
if ($ret > 0) {
message("Killed child: $child_pid");