fix jobless mksh so much to make it work on Minix 3
This commit is contained in:
8
Build.sh
8
Build.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.383 2009/04/05 12:21:14 tg Exp $'
|
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.384 2009/04/05 12:35:28 tg Exp $'
|
||||||
#-
|
#-
|
||||||
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
|
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
|
||||||
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NOPWNAM MKSH_NOVI
|
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NOPWNAM MKSH_NOVI
|
||||||
@ -324,9 +324,9 @@ MidnightBSD)
|
|||||||
Minix)
|
Minix)
|
||||||
CPPFLAGS="$CPPFLAGS -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2"
|
CPPFLAGS="$CPPFLAGS -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2"
|
||||||
CPPFLAGS="$CPPFLAGS -DMKSH_UNEMPLOYED -D_MINIX"
|
CPPFLAGS="$CPPFLAGS -DMKSH_UNEMPLOYED -D_MINIX"
|
||||||
warn=' and will currently not work'
|
warn=" but will probably work with GCC"
|
||||||
# warn=" but might work with the GNU tools"
|
warn="$warn${nl}but not with ACK - /usr/bin/cc - yet)"
|
||||||
# warn="$warn${nl}but not with ACK - /usr/bin/cc - yet)"
|
oldish_ed=no-stderr-ed # /usr/bin/ed(!) is broken
|
||||||
: ${HAVE_SETLOCALE_CTYPE=0}
|
: ${HAVE_SETLOCALE_CTYPE=0}
|
||||||
;;
|
;;
|
||||||
MirBSD)
|
MirBSD)
|
||||||
|
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.267 2009/04/03 09:39:03 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.268 2009/04/05 12:35:29 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas 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: 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 $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -7,7 +7,7 @@
|
|||||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R37 2009/04/03
|
@(#)MIRBSD KSH R37 2009/04/05
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
|
6
funcs.c
6
funcs.c
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.102 2009/04/03 09:45:23 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.103 2009/04/05 12:35:30 tg Exp $");
|
||||||
|
|
||||||
/* A leading = means assignments before command are kept;
|
/* A leading = means assignments before command are kept;
|
||||||
* a leading * means a POSIX special builtin;
|
* a leading * means a POSIX special builtin;
|
||||||
@ -51,8 +51,10 @@ const struct builtin mkshbuiltins[] = {
|
|||||||
{"=typeset", c_typeset},
|
{"=typeset", c_typeset},
|
||||||
{"+unalias", c_unalias},
|
{"+unalias", c_unalias},
|
||||||
{"whence", c_whence},
|
{"whence", c_whence},
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
{"+bg", c_fgbg},
|
{"+bg", c_fgbg},
|
||||||
{"+fg", c_fgbg},
|
{"+fg", c_fgbg},
|
||||||
|
#endif
|
||||||
{"bind", c_bind},
|
{"bind", c_bind},
|
||||||
#if HAVE_MKNOD
|
#if HAVE_MKNOD
|
||||||
{"mknod", c_mknod},
|
{"mknod", c_mknod},
|
||||||
@ -1238,6 +1240,7 @@ c_jobs(const char **wp)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
int
|
int
|
||||||
c_fgbg(const char **wp)
|
c_fgbg(const char **wp)
|
||||||
{
|
{
|
||||||
@ -1258,6 +1261,7 @@ c_fgbg(const char **wp)
|
|||||||
rv = j_resume("%%", bg);
|
rv = j_resume("%%", bg);
|
||||||
return bg ? 0 : rv;
|
return bg ? 0 : rv;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* format a single kill item */
|
/* format a single kill item */
|
||||||
static char *
|
static char *
|
||||||
|
58
jobs.c
58
jobs.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.48 2009/04/03 09:48:10 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.49 2009/04/05 12:35:31 tg Exp $");
|
||||||
|
|
||||||
/* Order important! */
|
/* Order important! */
|
||||||
#define PRUNNING 0
|
#define PRUNNING 0
|
||||||
@ -59,8 +59,10 @@ struct job {
|
|||||||
Proc *proc_list; /* process list */
|
Proc *proc_list; /* process list */
|
||||||
Proc *last_proc; /* last process in list */
|
Proc *last_proc; /* last process in list */
|
||||||
Coproc_id coproc_id; /* 0 or id of coprocess output pipe */
|
Coproc_id coproc_id; /* 0 or id of coprocess output pipe */
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
struct termios ttystate;/* saved tty state for stopped jobs */
|
struct termios ttystate;/* saved tty state for stopped jobs */
|
||||||
pid_t saved_ttypgrp; /* saved tty process group for stopped jobs */
|
pid_t saved_ttypgrp; /* saved tty process group for stopped jobs */
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Flags for j_waitj() */
|
/* Flags for j_waitj() */
|
||||||
@ -102,10 +104,12 @@ static int32_t njobs; /* # of jobs started */
|
|||||||
/* held_sigchld is set if sigchld occurs before a job is completely started */
|
/* held_sigchld is set if sigchld occurs before a job is completely started */
|
||||||
static volatile sig_atomic_t held_sigchld;
|
static volatile sig_atomic_t held_sigchld;
|
||||||
|
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
static struct shf *shl_j;
|
static struct shf *shl_j;
|
||||||
static bool ttypgrp_ok; /* set if can use tty pgrps */
|
static bool ttypgrp_ok; /* set if can use tty pgrps */
|
||||||
static pid_t restore_ttypgrp = -1;
|
static pid_t restore_ttypgrp = -1;
|
||||||
static int const tt_sigs[] = { SIGTSTP, SIGTTIN, SIGTTOU };
|
static int const tt_sigs[] = { SIGTSTP, SIGTTIN, SIGTTOU };
|
||||||
|
#endif
|
||||||
|
|
||||||
static void j_set_async(Job *);
|
static void j_set_async(Job *);
|
||||||
static void j_startjob(Job *);
|
static void j_startjob(Job *);
|
||||||
@ -122,8 +126,14 @@ static int kill_job(Job *, int);
|
|||||||
|
|
||||||
/* initialise job control */
|
/* initialise job control */
|
||||||
void
|
void
|
||||||
j_init(int mflagset)
|
j_init(void)
|
||||||
{
|
{
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
|
bool mflagset = Flag(FMONITOR) != 127;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Flag(FMONITOR) = 0;
|
||||||
|
|
||||||
(void)sigemptyset(&sm_default);
|
(void)sigemptyset(&sm_default);
|
||||||
sigprocmask(SIG_SETMASK, &sm_default, NULL);
|
sigprocmask(SIG_SETMASK, &sm_default, NULL);
|
||||||
|
|
||||||
@ -136,7 +146,6 @@ j_init(int mflagset)
|
|||||||
#ifndef MKSH_UNEMPLOYED
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (!mflagset && Flag(FTALKING))
|
if (!mflagset && Flag(FTALKING))
|
||||||
Flag(FMONITOR) = 1;
|
Flag(FMONITOR) = 1;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* shl_j is used to do asynchronous notification (used in
|
/* shl_j is used to do asynchronous notification (used in
|
||||||
* an interrupt handler, so need a distinct shf)
|
* an interrupt handler, so need a distinct shf)
|
||||||
@ -160,7 +169,9 @@ j_init(int mflagset)
|
|||||||
/* j_change() calls tty_init() */
|
/* j_change() calls tty_init() */
|
||||||
if (Flag(FMONITOR))
|
if (Flag(FMONITOR))
|
||||||
j_change();
|
j_change();
|
||||||
else if (Flag(FTALKING))
|
else
|
||||||
|
#endif
|
||||||
|
if (Flag(FTALKING))
|
||||||
tty_init(true, true);
|
tty_init(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,18 +194,21 @@ j_exit(void)
|
|||||||
kill_job(j, SIGHUP);
|
kill_job(j, SIGHUP);
|
||||||
else
|
else
|
||||||
killpg(j->pgrp, SIGHUP);
|
killpg(j->pgrp, SIGHUP);
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (j->state == PSTOPPED) {
|
if (j->state == PSTOPPED) {
|
||||||
if (j->pgrp == 0)
|
if (j->pgrp == 0)
|
||||||
kill_job(j, SIGCONT);
|
kill_job(j, SIGCONT);
|
||||||
else
|
else
|
||||||
killpg(j->pgrp, SIGCONT);
|
killpg(j->pgrp, SIGCONT);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (killed)
|
if (killed)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
j_notify();
|
j_notify();
|
||||||
|
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (kshpid == procpid && restore_ttypgrp >= 0) {
|
if (kshpid == procpid && restore_ttypgrp >= 0) {
|
||||||
/* Need to restore the tty pgrp to what it was when the
|
/* Need to restore the tty pgrp to what it was when the
|
||||||
* shell started up, so that the process that started us
|
* shell started up, so that the process that started us
|
||||||
@ -210,8 +224,10 @@ j_exit(void)
|
|||||||
Flag(FMONITOR) = 0;
|
Flag(FMONITOR) = 0;
|
||||||
j_change();
|
j_change();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
/* turn job control on or off according to Flag(FMONITOR) */
|
/* turn job control on or off according to Flag(FMONITOR) */
|
||||||
void
|
void
|
||||||
j_change(void)
|
j_change(void)
|
||||||
@ -288,6 +304,7 @@ j_change(void)
|
|||||||
tty_close();
|
tty_close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* execute tree in child subprocess */
|
/* execute tree in child subprocess */
|
||||||
int
|
int
|
||||||
@ -377,6 +394,7 @@ exchild(struct op *t, int flags,
|
|||||||
change_random(((unsigned long)p->pid << 1) | (ischild ? 1 : 0));
|
change_random(((unsigned long)p->pid << 1) | (ischild ? 1 : 0));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
/* job control set up */
|
/* job control set up */
|
||||||
if (Flag(FMONITOR) && !(flags&XXCOM)) {
|
if (Flag(FMONITOR) && !(flags&XXCOM)) {
|
||||||
int dotty = 0;
|
int dotty = 0;
|
||||||
@ -392,6 +410,7 @@ exchild(struct op *t, int flags,
|
|||||||
if (ttypgrp_ok && dotty && !(flags & XBGND))
|
if (ttypgrp_ok && dotty && !(flags & XBGND))
|
||||||
tcsetpgrp(tty_fd, j->pgrp);
|
tcsetpgrp(tty_fd, j->pgrp);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* used to close pipe input fd */
|
/* used to close pipe input fd */
|
||||||
if (close_fd >= 0 && (((flags & XPCLOSE) && !ischild) ||
|
if (close_fd >= 0 && (((flags & XPCLOSE) && !ischild) ||
|
||||||
@ -403,6 +422,7 @@ exchild(struct op *t, int flags,
|
|||||||
coproc_cleanup(false);
|
coproc_cleanup(false);
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
cleanup_parents_env();
|
cleanup_parents_env();
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
/* If FMONITOR or FTALKING is set, these signals are ignored,
|
/* If FMONITOR or FTALKING is set, these signals are ignored,
|
||||||
* if neither FMONITOR nor FTALKING are set, the signals have
|
* if neither FMONITOR nor FTALKING are set, the signals have
|
||||||
* their inherited values.
|
* their inherited values.
|
||||||
@ -412,6 +432,7 @@ exchild(struct op *t, int flags,
|
|||||||
setsig(&sigtraps[tt_sigs[i]], SIG_DFL,
|
setsig(&sigtraps[tt_sigs[i]], SIG_DFL,
|
||||||
SS_RESTORE_DFL|SS_FORCE);
|
SS_RESTORE_DFL|SS_FORCE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#if HAVE_NICE
|
#if HAVE_NICE
|
||||||
if (Flag(FBGNICE) && (flags & XBGND))
|
if (Flag(FBGNICE) && (flags & XBGND))
|
||||||
(void)nice(4);
|
(void)nice(4);
|
||||||
@ -429,8 +450,10 @@ exchild(struct op *t, int flags,
|
|||||||
}
|
}
|
||||||
remove_job(j, "child"); /* in case of $(jobs) command */
|
remove_job(j, "child"); /* in case of $(jobs) command */
|
||||||
nzombie = 0;
|
nzombie = 0;
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
ttypgrp_ok = false;
|
ttypgrp_ok = false;
|
||||||
Flag(FMONITOR) = 0;
|
Flag(FMONITOR) = 0;
|
||||||
|
#endif
|
||||||
Flag(FTALKING) = 0;
|
Flag(FTALKING) = 0;
|
||||||
tty_close();
|
tty_close();
|
||||||
cleartraps();
|
cleartraps();
|
||||||
@ -591,8 +614,10 @@ j_kill(const char *cp, int sig)
|
|||||||
rv = 1;
|
rv = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP))
|
if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP))
|
||||||
(void) killpg(j->pgrp, SIGCONT);
|
(void)killpg(j->pgrp, SIGCONT);
|
||||||
|
#endif
|
||||||
if (killpg(j->pgrp, sig) < 0) {
|
if (killpg(j->pgrp, sig) < 0) {
|
||||||
bi_errorf("%s: %s", cp, strerror(errno));
|
bi_errorf("%s: %s", cp, strerror(errno));
|
||||||
rv = 1;
|
rv = 1;
|
||||||
@ -604,6 +629,7 @@ j_kill(const char *cp, int sig)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
/* fg and bg built-ins: called only if Flag(FMONITOR) set */
|
/* fg and bg built-ins: called only if Flag(FMONITOR) set */
|
||||||
int
|
int
|
||||||
j_resume(const char *cp, int bg)
|
j_resume(const char *cp, int bg)
|
||||||
@ -705,6 +731,7 @@ j_resume(const char *cp, int bg)
|
|||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* are there any running or stopped jobs ? */
|
/* are there any running or stopped jobs ? */
|
||||||
int
|
int
|
||||||
@ -714,8 +741,10 @@ j_stopped_running(void)
|
|||||||
int which = 0;
|
int which = 0;
|
||||||
|
|
||||||
for (j = job_list; j != NULL; j = j->next) {
|
for (j = job_list; j != NULL; j = j->next) {
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (j->ppid == procpid && j->state == PSTOPPED)
|
if (j->ppid == procpid && j->state == PSTOPPED)
|
||||||
which |= 1;
|
which |= 1;
|
||||||
|
#endif
|
||||||
if (Flag(FLOGIN) && !Flag(FNOHUP) && procpid == kshpid &&
|
if (Flag(FLOGIN) && !Flag(FNOHUP) && procpid == kshpid &&
|
||||||
j->ppid == procpid && j->state == PRUNNING)
|
j->ppid == procpid && j->state == PRUNNING)
|
||||||
which |= 2;
|
which |= 2;
|
||||||
@ -803,8 +832,10 @@ j_notify(void)
|
|||||||
|
|
||||||
sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
|
sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
|
||||||
for (j = job_list; j; j = j->next) {
|
for (j = job_list; j; j = j->next) {
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (Flag(FMONITOR) && (j->flags & JF_CHANGED))
|
if (Flag(FMONITOR) && (j->flags & JF_CHANGED))
|
||||||
j_print(j, JP_MEDIUM, shl_out);
|
j_print(j, JP_MEDIUM, shl_out);
|
||||||
|
#endif
|
||||||
/* Remove job after doing reports so there aren't
|
/* Remove job after doing reports so there aren't
|
||||||
* multiple +/- jobs.
|
* multiple +/- jobs.
|
||||||
*/
|
*/
|
||||||
@ -932,9 +963,8 @@ j_waitj(Job *j,
|
|||||||
j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY);
|
j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY);
|
||||||
|
|
||||||
if (j->flags & JF_FG) {
|
if (j->flags & JF_FG) {
|
||||||
int status;
|
|
||||||
|
|
||||||
j->flags &= ~JF_FG;
|
j->flags &= ~JF_FG;
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (Flag(FMONITOR) && ttypgrp_ok && j->pgrp) {
|
if (Flag(FMONITOR) && ttypgrp_ok && j->pgrp) {
|
||||||
/*
|
/*
|
||||||
* Save the tty's current pgrp so it can be restored
|
* Save the tty's current pgrp so it can be restored
|
||||||
@ -959,6 +989,7 @@ j_waitj(Job *j,
|
|||||||
tcgetattr(tty_fd, &j->ttystate);
|
tcgetattr(tty_fd, &j->ttystate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (tty_fd >= 0) {
|
if (tty_fd >= 0) {
|
||||||
/* Only restore tty settings if job was originally
|
/* Only restore tty settings if job was originally
|
||||||
* started in the foreground. Problems can be
|
* started in the foreground. Problems can be
|
||||||
@ -988,17 +1019,23 @@ j_waitj(Job *j,
|
|||||||
j->flags &= ~JF_USETTYMODE;
|
j->flags &= ~JF_USETTYMODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
/* If it looks like user hit ^C to kill a job, pretend we got
|
/* If it looks like user hit ^C to kill a job, pretend we got
|
||||||
* one too to break out of for loops, etc. (at&t ksh does this
|
* one too to break out of for loops, etc. (at&t ksh does this
|
||||||
* even when not monitoring, but this doesn't make sense since
|
* even when not monitoring, but this doesn't make sense since
|
||||||
* a tty generated ^C goes to the whole process group)
|
* a tty generated ^C goes to the whole process group)
|
||||||
*/
|
*/
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
status = j->last_proc->status;
|
status = j->last_proc->status;
|
||||||
if (Flag(FMONITOR) && j->state == PSIGNALLED &&
|
if (Flag(FMONITOR) && j->state == PSIGNALLED &&
|
||||||
(WIFSIGNALED(status)) &&
|
(WIFSIGNALED(status)) &&
|
||||||
(sigtraps[WTERMSIG(status)].flags & TF_TTY_INTR))
|
(sigtraps[WTERMSIG(status)].flags & TF_TTY_INTR))
|
||||||
trapsig(WTERMSIG(status));
|
trapsig(WTERMSIG(status));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
j_usrtime = j->usrtime;
|
j_usrtime = j->usrtime;
|
||||||
j_systime = j->systime;
|
j_systime = j->systime;
|
||||||
@ -1072,9 +1109,12 @@ j_sigchld(int sig __unused)
|
|||||||
timersub(&j->systime, &ru0.ru_stime, &j->systime);
|
timersub(&j->systime, &ru0.ru_stime, &j->systime);
|
||||||
ru0 = ru1;
|
ru0 = ru1;
|
||||||
p->status = status;
|
p->status = status;
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (WIFSTOPPED(status))
|
if (WIFSTOPPED(status))
|
||||||
p->state = PSTOPPED;
|
p->state = PSTOPPED;
|
||||||
else if (WIFSIGNALED(status))
|
else
|
||||||
|
#endif
|
||||||
|
if (WIFSIGNALED(status))
|
||||||
p->state = PSIGNALLED;
|
p->state = PSIGNALLED;
|
||||||
else
|
else
|
||||||
p->state = PEXITED;
|
p->state = PEXITED;
|
||||||
@ -1152,6 +1192,7 @@ check_job(Job *j)
|
|||||||
}
|
}
|
||||||
|
|
||||||
j->flags |= JF_CHANGED;
|
j->flags |= JF_CHANGED;
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (Flag(FMONITOR) && !(j->flags & JF_XXCOM)) {
|
if (Flag(FMONITOR) && !(j->flags & JF_XXCOM)) {
|
||||||
/* Only put stopped jobs at the front to avoid confusing
|
/* Only put stopped jobs at the front to avoid confusing
|
||||||
* the user (don't want finished jobs effecting %+ or %-)
|
* the user (don't want finished jobs effecting %+ or %-)
|
||||||
@ -1180,6 +1221,7 @@ check_job(Job *j)
|
|||||||
remove_job(j, "notify");
|
remove_job(j, "notify");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (!Flag(FMONITOR) && !(j->flags & (JF_WAITING|JF_FG)) &&
|
if (!Flag(FMONITOR) && !(j->flags & (JF_WAITING|JF_FG)) &&
|
||||||
j->state != PSTOPPED) {
|
j->state != PSTOPPED) {
|
||||||
if (j == async_job || (j->flags & JF_KNOWN)) {
|
if (j == async_job || (j->flags & JF_KNOWN)) {
|
||||||
|
11
main.c
11
main.c
@ -13,7 +13,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.123 2009/04/05 11:44:56 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.124 2009/04/05 12:35:31 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -40,8 +40,11 @@ static const char *initcoms[] = {
|
|||||||
"alias",
|
"alias",
|
||||||
"hash=alias -t", /* not "alias -t --": hash -r needs to work */
|
"hash=alias -t", /* not "alias -t --": hash -r needs to work */
|
||||||
"type=whence -v",
|
"type=whence -v",
|
||||||
|
#ifndef notyet_MKSH_UNEMPLOYED
|
||||||
|
/* the alias list must be constant, for the regression test suite */
|
||||||
"stop=kill -STOP",
|
"stop=kill -STOP",
|
||||||
"suspend=kill -STOP $$",
|
"suspend=kill -STOP $$",
|
||||||
|
#endif
|
||||||
"autoload=typeset -fu",
|
"autoload=typeset -fu",
|
||||||
"functions=typeset -f",
|
"functions=typeset -f",
|
||||||
"history=fc -l",
|
"history=fc -l",
|
||||||
@ -309,10 +312,8 @@ main(int argc, const char *argv[])
|
|||||||
reset_nonblock(0);
|
reset_nonblock(0);
|
||||||
|
|
||||||
/* initialise job control */
|
/* initialise job control */
|
||||||
i = Flag(FMONITOR) != 127;
|
j_init();
|
||||||
Flag(FMONITOR) = 0;
|
/* Do this after j_init(), as tty_fd is not initialised until then */
|
||||||
j_init(i);
|
|
||||||
/* Do this after j_init(), as tty_fd is not initialised 'til then */
|
|
||||||
if (Flag(FTALKING)) {
|
if (Flag(FTALKING)) {
|
||||||
#ifndef MKSH_ASSUME_UTF8
|
#ifndef MKSH_ASSUME_UTF8
|
||||||
#define isuc(x) (((x) != NULL) && \
|
#define isuc(x) (((x) != NULL) && \
|
||||||
|
13
misc.c
13
misc.c
@ -9,7 +9,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.101 2009/04/03 10:54:58 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.102 2009/04/05 12:35:32 tg Exp $");
|
||||||
|
|
||||||
#undef USE_CHVT
|
#undef USE_CHVT
|
||||||
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
||||||
@ -100,13 +100,19 @@ const struct shoption options[] = {
|
|||||||
{ "keyword", 'k', OF_ANY },
|
{ "keyword", 'k', OF_ANY },
|
||||||
{ "login", 'l', OF_CMDLINE },
|
{ "login", 'l', OF_CMDLINE },
|
||||||
{ "markdirs", 'X', OF_ANY },
|
{ "markdirs", 'X', OF_ANY },
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
{ "monitor", 'm', OF_ANY },
|
{ "monitor", 'm', OF_ANY },
|
||||||
|
#else
|
||||||
|
{ NULL, 'm', 0 }, /* needed */
|
||||||
|
#endif
|
||||||
{ "noclobber", 'C', OF_ANY },
|
{ "noclobber", 'C', OF_ANY },
|
||||||
{ "noexec", 'n', OF_ANY },
|
{ "noexec", 'n', OF_ANY },
|
||||||
{ "noglob", 'f', OF_ANY },
|
{ "noglob", 'f', OF_ANY },
|
||||||
{ "nohup", 0, OF_ANY },
|
{ "nohup", 0, OF_ANY },
|
||||||
{ "nolog", 0, OF_ANY }, /* no effect */
|
{ "nolog", 0, OF_ANY }, /* no effect */
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
{ "notify", 'b', OF_ANY },
|
{ "notify", 'b', OF_ANY },
|
||||||
|
#endif
|
||||||
{ "nounset", 'u', OF_ANY },
|
{ "nounset", 'u', OF_ANY },
|
||||||
{ "physical", 0, OF_ANY }, /* non-standard */
|
{ "physical", 0, OF_ANY }, /* non-standard */
|
||||||
{ "posix", 0, OF_ANY }, /* non-standard */
|
{ "posix", 0, OF_ANY }, /* non-standard */
|
||||||
@ -219,10 +225,13 @@ change_flag(enum sh_flag f,
|
|||||||
|
|
||||||
oldval = Flag(f);
|
oldval = Flag(f);
|
||||||
Flag(f) = newval ? 1 : 0; /* needed for tristates */
|
Flag(f) = newval ? 1 : 0; /* needed for tristates */
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
if (f == FMONITOR) {
|
if (f == FMONITOR) {
|
||||||
if (what != OF_CMDLINE && newval != oldval)
|
if (what != OF_CMDLINE && newval != oldval)
|
||||||
j_change();
|
j_change();
|
||||||
} else if ((
|
} else
|
||||||
|
#endif
|
||||||
|
if ((
|
||||||
#ifndef MKSH_NOVI
|
#ifndef MKSH_NOVI
|
||||||
f == FVI ||
|
f == FVI ||
|
||||||
#endif
|
#endif
|
||||||
|
14
sh.h
14
sh.h
@ -102,9 +102,9 @@
|
|||||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.287 2009/04/03 09:39:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.288 2009/04/05 12:35:32 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R37 2009/04/03"
|
#define MKSH_VERSION "R37 2009/04/05"
|
||||||
|
|
||||||
#ifndef MKSH_INCLUDES_ONLY
|
#ifndef MKSH_INCLUDES_ONLY
|
||||||
|
|
||||||
@ -512,7 +512,9 @@ enum sh_flag {
|
|||||||
FNOGLOB, /* -f: don't do file globbing */
|
FNOGLOB, /* -f: don't do file globbing */
|
||||||
FNOHUP, /* -H: don't kill running jobs when login shell exits */
|
FNOHUP, /* -H: don't kill running jobs when login shell exits */
|
||||||
FNOLOG, /* don't save functions in history (ignored) */
|
FNOLOG, /* don't save functions in history (ignored) */
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
FNOTIFY, /* -b: asynchronous job completion notification */
|
FNOTIFY, /* -b: asynchronous job completion notification */
|
||||||
|
#endif
|
||||||
FNOUNSET, /* -u: using an unset var is an error */
|
FNOUNSET, /* -u: using an unset var is an error */
|
||||||
FPHYSICAL, /* -o physical: don't do logical cds/pwds */
|
FPHYSICAL, /* -o physical: don't do logical cds/pwds */
|
||||||
FPOSIX, /* -o posix (try to be more compatible) */
|
FPOSIX, /* -o posix (try to be more compatible) */
|
||||||
@ -1333,7 +1335,9 @@ int c_alias(const char **);
|
|||||||
int c_unalias(const char **);
|
int c_unalias(const char **);
|
||||||
int c_let(const char **);
|
int c_let(const char **);
|
||||||
int c_jobs(const char **);
|
int c_jobs(const char **);
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
int c_fgbg(const char **);
|
int c_fgbg(const char **);
|
||||||
|
#endif
|
||||||
int c_kill(const char **);
|
int c_kill(const char **);
|
||||||
void getopts_reset(int);
|
void getopts_reset(int);
|
||||||
int c_getopts(const char **);
|
int c_getopts(const char **);
|
||||||
@ -1398,15 +1402,19 @@ void restore_pipe(int);
|
|||||||
int setsig(Trap *, sig_t, int);
|
int setsig(Trap *, sig_t, int);
|
||||||
void setexecsig(Trap *, int);
|
void setexecsig(Trap *, int);
|
||||||
/* jobs.c */
|
/* jobs.c */
|
||||||
void j_init(int);
|
void j_init(void);
|
||||||
void j_exit(void);
|
void j_exit(void);
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
void j_change(void);
|
void j_change(void);
|
||||||
|
#endif
|
||||||
int exchild(struct op *, int, volatile int *, int);
|
int exchild(struct op *, int, volatile int *, int);
|
||||||
void startlast(void);
|
void startlast(void);
|
||||||
int waitlast(void);
|
int waitlast(void);
|
||||||
int waitfor(const char *, int *);
|
int waitfor(const char *, int *);
|
||||||
int j_kill(const char *, int);
|
int j_kill(const char *, int);
|
||||||
|
#ifndef MKSH_UNEMPLOYED
|
||||||
int j_resume(const char *, int);
|
int j_resume(const char *, int);
|
||||||
|
#endif
|
||||||
int j_jobs(const char *, int, int);
|
int j_jobs(const char *, int, int);
|
||||||
int j_njobs(void);
|
int j_njobs(void);
|
||||||
void j_notify(void);
|
void j_notify(void);
|
||||||
|
Reference in New Issue
Block a user