experimental getpgrp(2) support for mksh

This commit is contained in:
tg 2005-01-18 17:12:22 +00:00
parent 490aa9b78d
commit 4075a35b8e
4 changed files with 22 additions and 7 deletions

View File

@ -1,4 +1,4 @@
.\" $MirBSD: src/bin/ksh/ksh.1tbl,v 2.10 2004/12/31 19:00:30 tg Exp $
.\" $MirBSD: src/bin/ksh/ksh.1tbl,v 2.11 2005/01/18 17:12:21 tg Exp $
.\" $OpenBSD: ksh.1tbl,v 1.84 2004/12/22 18:58:44 millert Exp $
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
.\"
@ -1493,6 +1493,9 @@ colon, or two adjacent colons, is treated as a
.Dq \&. ,
the current directory.
This is dangerous.
.It Ev PGRP
The current process group, see
.Xr getpgrp 2 .
.It Ev POSIXLY_CORRECT
If set, this parameter causes the
.Ic posix

6
main.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/main.c,v 2.15 2004/12/31 19:15:39 tg Exp $ */
/** $MirBSD: src/bin/ksh/main.c,v 2.16 2005/01/18 17:12:22 tg Exp $ */
/* $OpenBSD: main.c,v 1.35 2004/12/22 18:57:28 otto Exp $ */
/*
@ -15,7 +15,7 @@
* shell version
*/
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.15 2004/12/31 19:15:39 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.16 2005/01/18 17:12:22 tg Exp $");
const char ksh_version[] =
"@(#)PD KSH v5.2.14 MirOS R20 in "
@ -49,7 +49,7 @@ static const char initsubs[] = "${PS2=> } ${PS3=#? } ${PS4=+ }";
static const char *const initcoms [] = {
"typeset", "-x", "SHELL", "PATH", "HOME", NULL,
"typeset", "-r", "KSH_VERSION", NULL,
"typeset", "-i", "PPID", NULL,
"typeset", "-i", "PGRP=0", "PPID", NULL,
"typeset", "-i", "OPTIND=1", NULL,
"eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
"alias",

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/table.h,v 2.1 2004/12/10 18:09:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/table.h,v 2.2 2005/01/18 17:12:22 tg Exp $ */
/* $OpenBSD: table.h,v 1.5 1999/06/15 01:18:36 millert Exp $ */
/* $From: table.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */
@ -166,6 +166,7 @@ extern const struct builtin shbuiltins [], kshbuiltins [];
#define V_TMOUT 15
#define V_TMPDIR 16
#define V_LINENO 17
#define V_PGRP 18
/* values for set_prompt() */
#define PS1 0 /* command */

15
var.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/var.c,v 2.8 2004/12/31 19:37:03 tg Exp $ */
/** $MirBSD: src/bin/ksh/var.c,v 2.9 2005/01/18 17:12:22 tg Exp $ */
/* $OpenBSD: var.c,v 1.17 2004/05/08 19:42:35 deraadt Exp $ */
#include "sh.h"
@ -6,7 +6,7 @@
#include "ksh_stat.h"
#include <ctype.h>
__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.8 2004/12/31 19:37:03 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.9 2005/01/18 17:12:22 tg Exp $");
/*
* Variables
@ -101,6 +101,7 @@ initvar(void)
{ "SECONDS", V_SECONDS },
{ "TMOUT", V_TMOUT },
{ "LINENO", V_LINENO },
{ "PGRP", V_PGRP },
{ NULL, 0 }
};
int i;
@ -916,6 +917,16 @@ getspec(struct tbl *vp)
setint(vp, (long) current_lineno + user_lineno);
vp->flag |= SPECIAL;
break;
case V_PGRP:
#ifdef BSD_PGRP
#define getpgID() getpgrp(0)
#else
#define getpgID() getpgrp()
#endif
vp->flag &= ~SPECIAL;
setint(vp, getpgID());
vp->flag |= SPECIAL;
break;
}
}