mksh:
* initialise the integers PPID, OPTIND, RANDOM, SECONDS, and TMOUT to base-10 * bring back PGRP as base-10 integer to the process group via getpgrp(2) * initialise USER_ID as base-10 integer to the effective user id as retrieved from geteuid(2) = $(id -u) * use $USER_ID in dot.mkshrc instead of spawning an id(1) process -> dot.mkshrc,v 1.34 now requires mksh R34 * convert more int to bool where appropriate * remove dead code - getpgrp(2) cannot fail * sync manual page to reality * bump to mksh R34(beta) - feature freeze XXX check if our_pgrp in jobs.c is still really needed, the setpgid call XXX probably just makes us our own pgrp leader, and we might have to use XXX and update kshpgrp accordingly - need feedback/help here but I think XXX this simplification should be possible if I grok the code correctly. etc/profile: * adjust to $USER_ID changes in mksh (speed-up here, too) mksh.hts: * sync changelog
This commit is contained in:
12
main.c
12
main.c
@ -13,7 +13,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.96 2008/05/04 01:58:14 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.97 2008/05/15 15:24:10 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -32,8 +32,8 @@ static const char initsubs[] = "${PS2=> } ${PS3=#? } ${PS4=+ }";
|
||||
static const char *initcoms[] = {
|
||||
"typeset", "-r", initvsn, NULL,
|
||||
"typeset", "-x", "SHELL", "PATH", "HOME", NULL,
|
||||
"typeset", "-i", "PPID", "OPTIND=1", NULL,
|
||||
"eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
|
||||
"typeset", "-i10", "OPTIND=1", "PGRP", "PPID", "USER_ID", NULL,
|
||||
"eval", "typeset -i10 RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
|
||||
"alias", "integer=typeset -i", "local=typeset", NULL,
|
||||
"alias",
|
||||
"hash=alias -t", /* not "alias -t --": hash -r needs to work */
|
||||
@ -213,7 +213,6 @@ main(int argc, const char *argv[])
|
||||
#if HAVE_ARC4RANDOM
|
||||
Flag(FARC4RANDOM) = 2; /* use arc4random(3) until $RANDOM is written */
|
||||
#endif
|
||||
setint(global("PPID"), (long)ppid);
|
||||
|
||||
for (wp = initcoms; *wp != NULL; wp++) {
|
||||
shcomexec(wp);
|
||||
@ -228,6 +227,9 @@ main(int argc, const char *argv[])
|
||||
(!ksheuid && !strchr(str_val(vp), '#')))
|
||||
/* setstr can't fail here */
|
||||
setstr(vp, safe_prompt, KSH_RETURN_ERROR);
|
||||
setint(global("PGRP"), (long)(kshpgrp = getpgrp()));
|
||||
setint(global("PPID"), (long)ppid);
|
||||
setint(global("USER_ID"), (long)ksheuid);
|
||||
|
||||
/* Set this before parsing arguments */
|
||||
#if HAVE_SETRESUGID
|
||||
@ -636,7 +638,7 @@ quitenv(struct shf *shf)
|
||||
* dump a core..
|
||||
*/
|
||||
if ((sig == SIGINT || sig == SIGTERM) &&
|
||||
getpgrp() == kshpid) {
|
||||
(kshpgrp == kshpid)) {
|
||||
setsig(&sigtraps[sig], SIG_DFL,
|
||||
SS_RESTORE_CURR | SS_FORCE);
|
||||
kill(0, sig);
|
||||
|
Reference in New Issue
Block a user