Roland Mainz
2013-09-11 23:40:17 UTC
Hi!
----
Minor nit for kill -q/-Q in ast-ksh.2013-09-11: |sival_int| is a
signed integer while |sival_ptr| is an unsigned datatype:
-- snip --
$ ksh -c 'trap "print -v .sh.sig" RTMAX ; kill -q -9 -s RTMAX $$ ;
true' /home/test001/bin/ksh: kill: -9 - too large
for sizeof(integer)
-- snip --
Attached (as "astksh20130911_sigqueue_fixes001.diff.txt") is a patch
which fixes the issue (and the issues listed below...).
* Notes:
- $ kill -q ... # now handles signed integer as intended (note I'm
using |signed int| intentionally to underline that we want a signed
value)
- Updated $ kill --version #'s version number to reflect the addition of -Q
- $ kill -q ... # now clears |QQFLAG| to avoid hiccups if someone
accidently uses $ kill -Q $val -q $val ... # ...
- src/cmd/ksh93/sh/jobs.c now uses |(sig&JOB_QFLAG)?true:false| to
prevent "clang" from bitterly complaining about |bool| "abuse", e.g.
using an integer with a non-|1|/|0| value as value for |bool|
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
-------------- next part --------------
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/bltins/trap.c build_i386_64bit_debug_sigval_fix/src/cmd/ksh93/bltins/trap.c
--- src/cmd/ksh93/bltins/trap.c 2013-09-10 20:07:04.000000000 +0200
+++ src/cmd/ksh93/bltins/trap.c 2013-09-12 00:57:52.239918650 +0200
@@ -220,10 +220,11 @@
flag |= L_FLAG;
break;
case 'q':
+ flag &= ~QQ_FLAG;
flag |= Q_FLAG;
shp->sigval = opt_info.num;
- if((unsigned int)shp->sigval != shp->sigval)
- errormsg(SH_DICT,ERROR_exit(1), "%lld - too large for sizeof(integer)", shp->sigval);
+ if((signed int)shp->sigval != shp->sigval)
+ errormsg(SH_DICT,ERROR_exit(1), "%lld - does not fit into sizeof(integer)", shp->sigval);
break;
case 'Q':
flag |= Q_FLAG|QQ_FLAG;
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/data/builtins.c build_i386_64bit_debug_sigval_fix/src/cmd/ksh93/data/builtins.c
--- src/cmd/ksh93/data/builtins.c 2013-09-10 21:16:07.000000000 +0200
+++ src/cmd/ksh93/data/builtins.c 2013-09-12 00:58:51.511370538 +0200
@@ -1009,7 +1009,7 @@
;
const char sh_optkill[] =
-"[-1c?\n@(#)$Id: kill (AT&T Research) 2012-07-05 $\n]"
+"[-1c?\n@(#)$Id: kill (AT&T Research) 2013-09-10 $\n]"
USAGE_LICENSE
"[+NAME?kill - terminate or signal process]"
"[+DESCRIPTION?With the first form in which \b-l\b is not specified, "
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/sh/jobs.c build_i386_64bit_debug_sigval_fix/src/cmd/ksh93/sh/jobs.c
--- src/cmd/ksh93/sh/jobs.c 2013-09-10 20:06:35.000000000 +0200
+++ src/cmd/ksh93/sh/jobs.c 2013-09-12 01:15:58.713353698 +0200
@@ -1169,7 +1169,7 @@
register pid_t pid;
register int r;
const char *msg;
- int qflag = sig&JOB_QFLAG;
+ bool qflag = (sig&JOB_QFLAG)?true:false;
#ifdef SIGTSTP
bool stopsig;
#endif
@@ -1182,10 +1182,14 @@
goto error;
shp = pw->p_shp;
#if _lib_sigqueue
- if(sig&JOB_QQFLAG)
- sig_val.sival_ptr = pointerof(shp->sigval);
- else
- sig_val.sival_int = (int)shp->sigval;
+ if(qflag)
+ {
+ memset(&sig_val, 0, sizeof(sig_val));
+ if(sig&JOB_QQFLAG)
+ sig_val.sival_ptr = pointerof(shp->sigval);
+ else
+ sig_val.sival_int = (int)shp->sigval;
+ }
#endif
sig &= ~(JOB_QFLAG|JOB_QQFLAG);
#ifdef SIGTSTP
----
Minor nit for kill -q/-Q in ast-ksh.2013-09-11: |sival_int| is a
signed integer while |sival_ptr| is an unsigned datatype:
-- snip --
$ ksh -c 'trap "print -v .sh.sig" RTMAX ; kill -q -9 -s RTMAX $$ ;
true' /home/test001/bin/ksh: kill: -9 - too large
for sizeof(integer)
-- snip --
Attached (as "astksh20130911_sigqueue_fixes001.diff.txt") is a patch
which fixes the issue (and the issues listed below...).
* Notes:
- $ kill -q ... # now handles signed integer as intended (note I'm
using |signed int| intentionally to underline that we want a signed
value)
- Updated $ kill --version #'s version number to reflect the addition of -Q
- $ kill -q ... # now clears |QQFLAG| to avoid hiccups if someone
accidently uses $ kill -Q $val -q $val ... # ...
- src/cmd/ksh93/sh/jobs.c now uses |(sig&JOB_QFLAG)?true:false| to
prevent "clang" from bitterly complaining about |bool| "abuse", e.g.
using an integer with a non-|1|/|0| value as value for |bool|
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
-------------- next part --------------
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/bltins/trap.c build_i386_64bit_debug_sigval_fix/src/cmd/ksh93/bltins/trap.c
--- src/cmd/ksh93/bltins/trap.c 2013-09-10 20:07:04.000000000 +0200
+++ src/cmd/ksh93/bltins/trap.c 2013-09-12 00:57:52.239918650 +0200
@@ -220,10 +220,11 @@
flag |= L_FLAG;
break;
case 'q':
+ flag &= ~QQ_FLAG;
flag |= Q_FLAG;
shp->sigval = opt_info.num;
- if((unsigned int)shp->sigval != shp->sigval)
- errormsg(SH_DICT,ERROR_exit(1), "%lld - too large for sizeof(integer)", shp->sigval);
+ if((signed int)shp->sigval != shp->sigval)
+ errormsg(SH_DICT,ERROR_exit(1), "%lld - does not fit into sizeof(integer)", shp->sigval);
break;
case 'Q':
flag |= Q_FLAG|QQ_FLAG;
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/data/builtins.c build_i386_64bit_debug_sigval_fix/src/cmd/ksh93/data/builtins.c
--- src/cmd/ksh93/data/builtins.c 2013-09-10 21:16:07.000000000 +0200
+++ src/cmd/ksh93/data/builtins.c 2013-09-12 00:58:51.511370538 +0200
@@ -1009,7 +1009,7 @@
;
const char sh_optkill[] =
-"[-1c?\n@(#)$Id: kill (AT&T Research) 2012-07-05 $\n]"
+"[-1c?\n@(#)$Id: kill (AT&T Research) 2013-09-10 $\n]"
USAGE_LICENSE
"[+NAME?kill - terminate or signal process]"
"[+DESCRIPTION?With the first form in which \b-l\b is not specified, "
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/sh/jobs.c build_i386_64bit_debug_sigval_fix/src/cmd/ksh93/sh/jobs.c
--- src/cmd/ksh93/sh/jobs.c 2013-09-10 20:06:35.000000000 +0200
+++ src/cmd/ksh93/sh/jobs.c 2013-09-12 01:15:58.713353698 +0200
@@ -1169,7 +1169,7 @@
register pid_t pid;
register int r;
const char *msg;
- int qflag = sig&JOB_QFLAG;
+ bool qflag = (sig&JOB_QFLAG)?true:false;
#ifdef SIGTSTP
bool stopsig;
#endif
@@ -1182,10 +1182,14 @@
goto error;
shp = pw->p_shp;
#if _lib_sigqueue
- if(sig&JOB_QQFLAG)
- sig_val.sival_ptr = pointerof(shp->sigval);
- else
- sig_val.sival_int = (int)shp->sigval;
+ if(qflag)
+ {
+ memset(&sig_val, 0, sizeof(sig_val));
+ if(sig&JOB_QQFLAG)
+ sig_val.sival_ptr = pointerof(shp->sigval);
+ else
+ sig_val.sival_int = (int)shp->sigval;
+ }
#endif
sig &= ~(JOB_QFLAG|JOB_QQFLAG);
#ifdef SIGTSTP