fix a number of warnings and other issues:

• sig_t detection was a bit insane, it is a function-pointer type after all
• fix uninitialised variable in c_select which led to mistakenly accepting
  invalid (nōn-numeric) input and acting, randomly, upon it
• keep SIGCHLD blocked in child after forking longer, for job list manip
• block SIGCHLD ifdef DEBUG_LEAKS to not run job foo during/after afreeall
• fix annoying ISO C90 vs. C99 (un)signed constant warning
This commit is contained in:
tg 2013-06-02 03:09:17 +00:00
parent d16705415a
commit 8256f266ff
6 changed files with 29 additions and 20 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.636 2013/05/31 23:27:11 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.637 2013/06/02 03:09:11 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013
@ -1500,14 +1500,18 @@ ac_testn sig_t <<-'EOF'
#include <sys/types.h>
#include <signal.h>
#include <stddef.h>
int main(void) { return ((int)(ptrdiff_t)(sig_t)(ptrdiff_t)kill(0,0)); }
#include <stdlib.h>
volatile sig_t foo = NULL;
int main(void) { return (foo == NULL); }
EOF
ac_testn sighandler_t '!' sig_t 0 <<-'EOF'
#include <sys/types.h>
#include <signal.h>
#include <stddef.h>
int main(void) { return ((int)(ptrdiff_t)(sighandler_t)(ptrdiff_t)kill(0,0)); }
#include <stdlib.h>
volatile sighandler_t foo = NULL;
int main(void) { return (foo == NULL); }
EOF
if test 1 = $HAVE_SIGHANDLER_T; then
add_cppflags -Dsig_t=sighandler_t
@ -1518,7 +1522,9 @@ ac_testn __sighandler_t '!' sig_t 0 <<-'EOF'
#include <sys/types.h>
#include <signal.h>
#include <stddef.h>
int main(void) { return ((int)(ptrdiff_t)(__sighandler_t)(ptrdiff_t)kill(0,0)); }
#include <stdlib.h>
volatile __sighandler_t foo = NULL;
int main(void) { return (foo == NULL); }
EOF
if test 1 = $HAVE___SIGHANDLER_T; then
add_cppflags -Dsig_t=__sighandler_t
@ -1541,7 +1547,7 @@ else
#define EXTERN
#define MKSH_INCLUDES_ONLY
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.636 2013/05/31 23:27:11 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.637 2013/06/02 03:09:11 tg Exp $");
int main(void) { printf("Hello, World!\n"); return (0); }
EOF
case $cm in

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.614 2013/06/01 00:15:55 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.615 2013/06/02 03:09:12 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -29,7 +29,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout:
@(#)MIRBSD KSH R46 2013/05/31
@(#)MIRBSD KSH R46 2013/06/01
description:
Check version of shell.
stdin:
@ -38,7 +38,7 @@ name: KSH_VERSION
category: shell:legacy-no
---
expected-stdout:
@(#)LEGACY KSH R46 2013/05/31
@(#)LEGACY KSH R46 2013/06/01
description:
Check version of legacy shell.
stdin:

6
exec.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.120 2013/04/26 21:22:44 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.121 2013/06/02 03:09:14 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -1561,10 +1561,8 @@ do_selectargs(const char **ap, bool print_menu)
if (call_builtin(findcom("read", FC_BI), read_args, Tselect))
return (NULL);
s = str_val(global("REPLY"));
if (*s) {
getn(s, &i);
if (*s && getn(s, &i))
return ((i >= 1 && i <= argct) ? ap[i - 1] : null);
}
print_menu = true;
}
}

9
jobs.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.98 2013/06/01 20:34:01 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.99 2013/06/02 03:09:15 tg Exp $");
#if HAVE_KILLPG
#define mksh_killpg killpg
@ -503,9 +503,6 @@ exchild(struct op *t, int flags,
/* Do this before restoring signal */
if (flags & XCOPROC)
coproc_cleanup(false);
#ifndef MKSH_NOPROSPECTOFWORK
sigprocmask(SIG_SETMASK, &omask, NULL);
#endif
cleanup_parents_env();
#ifndef MKSH_UNEMPLOYED
/*
@ -540,6 +537,10 @@ exchild(struct op *t, int flags,
}
/* in case of $(jobs) command */
remove_job(j, "child");
#ifndef MKSH_NOPROSPECTOFWORK
/* remove_job needs SIGCHLD blocked still */
sigprocmask(SIG_SETMASK, &omask, NULL);
#endif
nzombie = 0;
#ifndef MKSH_UNEMPLOYED
ttypgrp_ok = false;

8
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.264 2013/05/02 20:21:43 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.265 2013/06/02 03:09:16 tg Exp $");
extern char **environ;
@ -451,7 +451,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
xc = 0;
--xc;
if ((xua2 != 2147483648UL) ||
(xl != -2147483648L) || (xul != 2147483648UL) ||
(xl != (-2147483647L-1)) || (xul != 2147483648UL) ||
(xi != -1) || (xui != 4294967295U) ||
(xa != 0) || (xua != 0) || (xc != 255))
errorf("integer wraparound test failed");
@ -1014,6 +1014,10 @@ quitenv(struct shf *shf)
#ifdef DEBUG_LEAKS
#ifndef MKSH_NO_CMDLINE_EDITING
x_done();
#endif
#ifndef MKSH_NOPROSPECTOFWORK
/* block at least SIGCHLD during/after afreeall */
sigprocmask(SIG_BLOCK, &sm_sigchld, NULL);
#endif
afreeall(APERM);
for (fd = 3; fd < NUFILE; fd++)

4
sh.h
View File

@ -164,9 +164,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.657 2013/06/01 00:15:58 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.658 2013/06/02 03:09:17 tg Exp $");
#endif
#define MKSH_VERSION "R46 2013/05/31"
#define MKSH_VERSION "R46 2013/06/01"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES