• fix 「mksh -lT1」 (it was broken due to getpgrp() et al. being
moved to early) • allow ‘-T’ for MKSH_SMALL too, the installer needs it sync clog
This commit is contained in:
parent
6fcacf577d
commit
f0bec87228
26
main.c
26
main.c
@ -33,7 +33,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.153 2009/10/17 21:16:02 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.154 2009/10/30 14:37:42 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -44,6 +44,7 @@ extern gid_t kshgid, kshegid;
|
||||
|
||||
static void reclaim(void);
|
||||
static void remove_temps(struct temp *);
|
||||
void chvt_reinit(void);
|
||||
|
||||
static const char initifs[] = "IFS= \t\n";
|
||||
|
||||
@ -85,6 +86,19 @@ static int initio_done;
|
||||
static struct env env;
|
||||
struct env *e = &env;
|
||||
|
||||
void
|
||||
chvt_reinit(void)
|
||||
{
|
||||
kshpid = procpid = getpid();
|
||||
ksheuid = geteuid();
|
||||
kshpgrp = getpgrp();
|
||||
kshppid = getppid();
|
||||
|
||||
#if !HAVE_ARC4RANDOM
|
||||
change_random(&kshstate_, sizeof(kshstate_));
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
@ -100,14 +114,8 @@ main(int argc, const char *argv[])
|
||||
char *cp;
|
||||
#endif
|
||||
|
||||
kshpid = procpid = getpid();
|
||||
ksheuid = geteuid();
|
||||
kshpgrp = getpgrp();
|
||||
kshppid = getppid();
|
||||
|
||||
#if !HAVE_ARC4RANDOM
|
||||
change_random(&kshstate_, sizeof(kshstate_));
|
||||
#endif
|
||||
/* do things like getpgrp() et al. */
|
||||
chvt_reinit();
|
||||
|
||||
/* make sure argv[] is sane */
|
||||
if (!*argv) {
|
||||
|
21
misc.c
21
misc.c
@ -29,13 +29,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.127 2009/10/30 00:57:38 tg Exp $");
|
||||
|
||||
#undef USE_CHVT
|
||||
/* XXX conditions correct? */
|
||||
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
||||
#define USE_CHVT
|
||||
#endif
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.128 2009/10/30 14:37:43 tg Exp $");
|
||||
|
||||
unsigned char chtypes[UCHAR_MAX + 1]; /* type bits for unsigned char */
|
||||
|
||||
@ -47,7 +41,7 @@ gid_t kshgid, kshegid;
|
||||
static int do_gmatch(const unsigned char *, const unsigned char *,
|
||||
const unsigned char *, const unsigned char *);
|
||||
static const unsigned char *cclass(const unsigned char *, int);
|
||||
#ifdef USE_CHVT
|
||||
#ifdef TIOCSCTTY
|
||||
static void chvt(const char *);
|
||||
#endif
|
||||
|
||||
@ -259,7 +253,7 @@ parse_args(const char **argv,
|
||||
/* see cmd_opts[] declaration */
|
||||
*p++ = 'o';
|
||||
*p++ = ':';
|
||||
#ifndef MKSH_SMALL
|
||||
#if !defined(MKSH_SMALL) || defined(TIOCSCTTY)
|
||||
*p++ = 'T';
|
||||
*p++ = ':';
|
||||
#endif
|
||||
@ -337,11 +331,11 @@ parse_args(const char **argv,
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef MKSH_SMALL
|
||||
#if !defined(MKSH_SMALL) || defined(TIOCSCTTY)
|
||||
case 'T':
|
||||
if (what != OF_FIRSTTIME)
|
||||
break;
|
||||
#ifndef USE_CHVT
|
||||
#ifndef TIOCSCTTY
|
||||
errorf("no TIOCSCTTY ioctl");
|
||||
#else
|
||||
change_flag(FTALKING, OF_CMDLINE, 1);
|
||||
@ -1232,7 +1226,9 @@ set_current_wd(char *pathl)
|
||||
afree(p, ATEMP);
|
||||
}
|
||||
|
||||
#ifdef USE_CHVT
|
||||
#ifdef TIOCSCTTY
|
||||
extern void chvt_reinit(void);
|
||||
|
||||
static void
|
||||
chvt(const char *fn)
|
||||
{
|
||||
@ -1292,6 +1288,7 @@ chvt(const char *fn)
|
||||
ksh_dup2(fd, 2, false);
|
||||
if (fd > 2)
|
||||
close(fd);
|
||||
chvt_reinit();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user