summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ppp/log.c12
-rw-r--r--usr.sbin/ppp/main.c46
-rw-r--r--usr.sbin/ppp/prompt.c47
-rw-r--r--usr.sbin/ppp/prompt.h5
4 files changed, 67 insertions, 43 deletions
diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c
index 84c7c4820043..e8ad3e05b6c4 100644
--- a/usr.sbin/ppp/log.c
+++ b/usr.sbin/ppp/log.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: log.c,v 1.25.2.2 1998/04/03 19:25:40 brian Exp $
+ * $Id: log.c,v 1.25.2.3 1998/04/03 19:26:40 brian Exp $
*/
#include <sys/param.h>
@@ -382,8 +382,14 @@ log_ShowWho(struct cmdargs const *arg)
{
struct prompt *p;
- for (p = logprompt; p; p = p->lognext)
- prompt_Printf(arg->prompt, "%s%s\n", p->who, p == arg->prompt ? " *" : "");
+ for (p = logprompt; p; p = p->lognext) {
+ prompt_Printf(arg->prompt, "%s", p->who);
+ if (p == arg->prompt)
+ prompt_Printf(arg->prompt, " *");
+ if (!p->active)
+ prompt_Printf(arg->prompt, " ^Z");
+ prompt_Printf(arg->prompt, "\n");
+ }
return 0;
}
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index ca85282b2d42..ebc2037faf13 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.121.2.42 1998/04/03 19:25:07 brian Exp $
+ * $Id: main.c,v 1.121.2.43 1998/04/03 19:25:42 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@@ -153,26 +153,16 @@ KillChild(int signo)
static void
TerminalCont(int signo)
{
- pending_signal(SIGCONT, SIG_DFL);
- pending_signal(SIGTSTP, TerminalStop);
- if (getpgrp() == prompt_pgrp(SignalPrompt)) {
- prompt_TtyCommandMode(SignalPrompt);
- log_RegisterPrompt(SignalPrompt);
- SignalPrompt->nonewline = 1;
- prompt_Required(SignalPrompt);
- }
+ signal(SIGCONT, SIG_DFL);
+ prompt_Continue(SignalPrompt);
}
static void
TerminalStop(int signo)
{
- pending_signal(SIGCONT, TerminalCont);
- if (getpgrp() == prompt_pgrp(SignalPrompt)) {
- prompt_TtyOldMode(SignalPrompt);
- log_UnRegisterPrompt(SignalPrompt);
- }
- pending_signal(SIGTSTP, SIG_DFL);
- kill(getpid(), signo);
+ prompt_Suspend(SignalPrompt);
+ signal(SIGCONT, TerminalCont);
+ raise(SIGSTOP);
}
#if 0 /* What's our passwd :-O */
@@ -379,30 +369,14 @@ main(int argc, char **argv)
pending_signal(SIGINT, CloseConnection);
pending_signal(SIGQUIT, CloseSession);
pending_signal(SIGALRM, SIG_IGN);
-#ifdef SIGPIPE
signal(SIGPIPE, SIG_IGN);
-#endif
- if (mode & MODE_INTER) {
-#ifdef SIGTSTP
+ if (mode & MODE_INTER)
pending_signal(SIGTSTP, TerminalStop);
-#endif
-#ifdef SIGTTIN
- pending_signal(SIGTTIN, TerminalStop);
-#endif
-#ifdef SIGTTOU
- pending_signal(SIGTTOU, SIG_IGN);
-#endif
- }
- if (!(mode & MODE_INTER)) {
+
#if 0 /* What's our passwd :-O */
-#ifdef SIGUSR1
- pending_signal(SIGUSR1, SetUpServer);
+ pending_signal(SIGUSR1, SetUpServer);
#endif
-#endif
-#ifdef SIGUSR2
- pending_signal(SIGUSR2, BringDownServer);
-#endif
- }
+ pending_signal(SIGUSR2, BringDownServer);
if (label) {
if (SelectSystem(bundle, label, CONFFILE, prompt) < 0) {
diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c
index fde5dd00a2c5..95c7552380b3 100644
--- a/usr.sbin/ppp/prompt.c
+++ b/usr.sbin/ppp/prompt.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: prompt.c,v 1.1.2.19 1998/04/03 19:26:28 brian Exp $
+ * $Id: prompt.c,v 1.1.2.20 1998/04/04 10:34:28 brian Exp $
*/
#include <sys/param.h>
@@ -122,6 +122,10 @@ prompt_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
int sets;
sets = 0;
+
+ if (!p->active)
+ return sets;
+
if (p->fd_in >= 0) {
if (r) {
FD_SET(p->fd_in, r);
@@ -304,6 +308,7 @@ prompt_Create(struct server *s, struct bundle *bundle, int fd)
p->TermMode = NULL;
p->nonewline = 1;
p->needprompt = 1;
+ p->active = 1;
p->bundle = bundle;
if (p->bundle)
bundle_RegisterDescriptor(p->bundle, &p->desc);
@@ -341,7 +346,7 @@ prompt_Destroy(struct prompt *p, int verbose)
void
prompt_Printf(struct prompt *p, const char *fmt,...)
{
- if (p) {
+ if (p && p->active) {
va_list ap;
va_start(ap, fmt);
@@ -354,7 +359,7 @@ prompt_Printf(struct prompt *p, const char *fmt,...)
void
prompt_vPrintf(struct prompt *p, const char *fmt, va_list ap)
{
- if (p) {
+ if (p && p->active) {
vfprintf(p->Term, fmt, ap);
fflush(p->Term);
}
@@ -485,3 +490,39 @@ PasswdCommand(struct cmdargs const *arg)
return 0;
}
+
+static struct pppTimer bgtimer;
+
+static void
+prompt_TimedContinue(void *v)
+{
+ prompt_Continue((struct prompt *)v);
+}
+
+void
+prompt_Continue(struct prompt *p)
+{
+ StopTimer(&bgtimer);
+ if (getpgrp() == prompt_pgrp(p)) {
+ prompt_TtyCommandMode(p);
+ p->nonewline = 1;
+ prompt_Required(p);
+ p->active = 1;
+ } else if (!p->owner) {
+ bgtimer.func = prompt_TimedContinue;
+ bgtimer.name = "prompt bg";
+ bgtimer.load = SECTICKS;
+ bgtimer.state = TIMER_STOPPED;
+ bgtimer.arg = p;
+ StartTimer(&bgtimer);
+ }
+}
+
+void
+prompt_Suspend(struct prompt *p)
+{
+ if (getpgrp() == prompt_pgrp(p)) {
+ prompt_TtyOldMode(p);
+ p->active = 0;
+ }
+}
diff --git a/usr.sbin/ppp/prompt.h b/usr.sbin/ppp/prompt.h
index eeab6ff99b28..9a43e22ce737 100644
--- a/usr.sbin/ppp/prompt.h
+++ b/usr.sbin/ppp/prompt.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: prompt.h,v 1.1.2.3 1998/02/17 19:28:13 brian Exp $
+ * $Id: prompt.h,v 1.1.2.4 1998/04/03 19:25:51 brian Exp $
*/
#define LOCAL_AUTH 0x01
@@ -45,6 +45,7 @@ struct prompt {
struct bundle *bundle; /* who I'm controlling */
unsigned nonewline : 1; /* need a newline before our prompt ? */
unsigned needprompt : 1; /* Show a prompt at the next UpdateSet() */
+ unsigned active : 1; /* Is the prompt active (^Z) */
char who[40]; /* Where do I come from */
@@ -74,6 +75,8 @@ extern void prompt_TtyTermMode(struct prompt *, struct datalink *);
extern void prompt_TtyOldMode(struct prompt *);
extern pid_t prompt_pgrp(struct prompt *);
extern int PasswdCommand(struct cmdargs const *);
+extern void prompt_Suspend(struct prompt *);
+extern void prompt_Continue(struct prompt *);
#define prompt_IsTermMode(p, dl) ((p)->TermMode == (dl) ? 1 : 0)
#define prompt_IsController(p) (!(p) || (p)->owner ? 0 : 1)
#define prompt_Required(p) ((p)->needprompt = 1)