• Check if killpg(3) is available; if not, use kill(2) with negative

process ID and hope it works (is POSIXly killpg-endowed)
• bump version
• sync clog
This commit is contained in:
tg 2009-06-08 20:34:40 +00:00
parent 5613b3a5ac
commit 571546c562
6 changed files with 43 additions and 23 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.399 2009/06/07 22:26:00 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.400 2009/06/08 20:34:37 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Thorsten Glaser <tg@mirbsd.org>
@ -378,7 +378,6 @@ Plan9)
PW32*)
HAVE_SIG_T=0 # incompatible
warn=' and will currently not work'
# missing: killpg()
: ${HAVE_SETLOCALE_CTYPE=0}
;;
QNX)
@ -1127,6 +1126,11 @@ ac_test getrusage <<-'EOF'
}
EOF
ac_test killpg <<-'EOF'
#include <signal.h>
int main(int ac) { return (killpg(123, ac)); }
EOF
ac_test mknod '' 'if to use mknod(), makedev() and friends' <<-'EOF'
#define MKSH_INCLUDES_ONLY
#include "sh.h"

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/Makefile,v 1.74 2009/05/16 16:59:31 tg Stab $
# $MirOS: src/bin/mksh/Makefile,v 1.75 2009/06/08 20:34:38 tg Stab $
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Thorsten Glaser <tg@mirbsd.org>
@ -36,11 +36,12 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 \
-DHAVE_STDINT_H=1 -DHAVE_RLIM_T=1 -DHAVE_SIG_T=1 \
-DHAVE_SYS_SIGNAME=1 -DHAVE_SYS_SIGLIST=1 -DHAVE_STRSIGNAL=0 \
-DHAVE_ARC4RANDOM=1 -DHAVE_ARC4RANDOM_PUSHB=1 \
-DHAVE_GETRUSAGE=1 -DHAVE_MKNOD=1 -DHAVE_MKSTEMP=1 \
-DHAVE_NICE=1 -DHAVE_REALPATH=1 -DHAVE_REVOKE=1 \
-DHAVE_SETLOCALE_CTYPE=0 -DHAVE_LANGINFO_CODESET=0 \
-DHAVE_SETMODE=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 \
-DHAVE_STRCASESTR=1 -DHAVE_STRLCPY=1 -DHAVE_ARC4RANDOM_DECL=1 \
-DHAVE_GETRUSAGE=1 -DHAVE_KILLPG=1 -DHAVE_MKNOD=1 \
-DHAVE_MKSTEMP=1 -DHAVE_NICE=1 -DHAVE_REALPATH=1 \
-DHAVE_REVOKE=1 -DHAVE_SETLOCALE_CTYPE=0 \
-DHAVE_LANGINFO_CODESET=0 -DHAVE_SETMODE=1 \
-DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 \
-DHAVE_STRLCPY=1 -DHAVE_ARC4RANDOM_DECL=1 \
-DHAVE_ARC4RANDOM_PUSHB_DECL=1 -DHAVE_FLOCK_DECL=1 \
-DHAVE_REVOKE_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
-DHAVE_PERSISTENT_HISTORY=1

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.285 2009/06/07 22:43:46 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.286 2009/06/08 20:34:38 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 $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R38 2009/06/07
@(#)MIRBSD KSH R38 2009/06/08
description:
Check version of shell.
stdin:

18
funcs.c
View File

@ -25,7 +25,18 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.110 2009/06/08 20:06:46 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.111 2009/06/08 20:34:39 tg Exp $");
#if HAVE_KILLPG
/*
* use killpg if < -1 since -1 does special things
* for some non-killpg-endowed kills
*/
#define mksh_kill(p,s) ((p) < -1 ? killpg(-(p), (s)) : kill((p), (s)))
#else
/* cross fingers and hope kill is killpg-endowed */
#define mksh_kill kill
#endif
/* A leading = means assignments before command are kept;
* a leading * means a POSIX special builtin;
@ -1390,10 +1401,7 @@ c_kill(const char **wp)
p);
rv = 1;
} else {
/* use killpg if < -1 since -1 does special things for
* some non-killpg-endowed kills
*/
if ((n < -1 ? killpg(-n, sig) : kill(n, sig)) < 0) {
if (mksh_kill(n, sig) < 0) {
bi_errorf("%s: %s", p, strerror(errno));
rv = 1;
}

19
jobs.c
View File

@ -22,7 +22,14 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.54 2009/06/08 20:06:47 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.55 2009/06/08 20:34:40 tg Exp $");
#if HAVE_KILLPG
#define mksh_killpg killpg
#else
/* cross fingers and hope kill is killpg-endowed */
#define mksh_killpg(p,s) kill(-(p), (s))
#endif
/* Order important! */
#define PRUNNING 0
@ -213,13 +220,13 @@ j_exit(void)
if (j->pgrp == 0)
kill_job(j, SIGHUP);
else
killpg(j->pgrp, SIGHUP);
mksh_killpg(j->pgrp, SIGHUP);
#ifndef MKSH_UNEMPLOYED
if (j->state == PSTOPPED) {
if (j->pgrp == 0)
kill_job(j, SIGCONT);
else
killpg(j->pgrp, SIGCONT);
mksh_killpg(j->pgrp, SIGCONT);
}
#endif
}
@ -636,9 +643,9 @@ j_kill(const char *cp, int sig)
} else {
#ifndef MKSH_UNEMPLOYED
if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP))
(void)killpg(j->pgrp, SIGCONT);
mksh_killpg(j->pgrp, SIGCONT);
#endif
if (killpg(j->pgrp, sig) < 0) {
if (mksh_killpg(j->pgrp, sig) < 0) {
bi_errorf("%s: %s", cp, strerror(errno));
rv = 1;
}
@ -725,7 +732,7 @@ j_resume(const char *cp, int bg)
async_job = NULL;
}
if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) < 0) {
if (j->state == PRUNNING && mksh_killpg(j->pgrp, SIGCONT) < 0) {
int err = errno;
if (!bg) {

4
sh.h
View File

@ -122,9 +122,9 @@
#define __SCCSID(x) __IDSTRING(sccsid,x)
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.307 2009/06/08 20:06:48 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.308 2009/06/08 20:34:40 tg Exp $");
#endif
#define MKSH_VERSION "R38 2009/06/07"
#define MKSH_VERSION "R38 2009/06/08"
#ifndef MKSH_INCLUDES_ONLY