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