changed to trap hangups and make them simulate quits
SCCS-vsn: usr.bin/mail/lex.c 1.16
* Lexical processing of commands.
*/
* Lexical processing of commands.
*/
-static char *SccsId = "@(#)lex.c 1.15 %G%";
+static char *SccsId = "@(#)lex.c 1.16 %G%";
/*
* Set up editing on the given file name.
/*
* Set up editing on the given file name.
static int shudclob;
static char efile[128];
extern char tempMesg[];
static int shudclob;
static char efile[128];
extern char tempMesg[];
if ((ibuf = fopen(name, "r")) == NULL) {
if (isedit)
if ((ibuf = fopen(name, "r")) == NULL) {
if (isedit)
* the message[] data structure.
*/
* the message[] data structure.
*/
- for (i = SIGINT; i <= SIGQUIT; i++)
- sigs[i - SIGINT] = signal(i, SIG_IGN);
+ sigsave(sigs, SIG_IGN);
if (shudclob) {
if (edit)
edstop();
if (shudclob) {
if (edit)
edstop();
setptr(ibuf);
setmsize(msgCount);
fclose(ibuf);
setptr(ibuf);
setmsize(msgCount);
fclose(ibuf);
- for (i = SIGINT; i <= SIGQUIT; i++)
- signal(i, sigs[i - SIGINT]);
shudann = 1;
sawcom = 0;
return(0);
shudann = 1;
sawcom = 0;
return(0);
int prompt, firstsw, stop();
register int n;
char linebuf[LINESIZE];
int prompt, firstsw, stop();
register int n;
char linebuf[LINESIZE];
- if (rcvmode)
- if (signal(SIGINT, SIG_IGN) == SIG_DFL)
- signal(SIGINT, stop);
+ if (rcvmode) {
+ if (sigset(SIGINT, SIG_IGN) != SIG_IGN)
+ sigset(SIGINT, stop);
+ if (sigset(SIGHUP, SIG_IGN) != SIG_IGN)
+ sigset(SIGHUP, hangup);
+ }
input = stdin;
prompt = 1;
if (!intty)
input = stdin;
prompt = 1;
if (!intty)
printf("Use \"quit\" to quit.\n");
goto top;
}
printf("Use \"quit\" to quit.\n");
goto top;
}
- if (!edit) {
- signal(SIGINT, SIG_IGN);
return(0);
}
if (!edit && com->c_func == edstop) {
return(0);
}
if (!edit && com->c_func == edstop) {
- signal(SIGINT, SIG_IGN);
+ sigset(SIGINT, SIG_IGN);
+/*
+ * Branch here on hangup signal and simulate quit.
+ */
+hangup()
+{
+ int (*sigs[3])();
+
+ sigsave(sigs);
+ if (edit) {
+ if (setexit())
+ exit(0);
+ edstop();
+ }
+ else
+ quit();
+ exit(0);
+}
+
/*
* Set the size of the message vector used to construct argument
* lists to message list functions.
/*
* Set the size of the message vector used to construct argument
* lists to message list functions.
int inithdr; /* am printing startup headers */
int inithdr; /* am printing startup headers */
{
register FILE *fp;
noreset = 0;
{
register FILE *fp;
noreset = 0;
- signal(SIGINT, SIG_IGN);
if (!inithdr)
sawcom++;
inithdr = 0;
if (!inithdr)
sawcom++;
inithdr = 0;
}
clrbuf(stdout);
printf("Interrupt\n");
}
clrbuf(stdout);
printf("Interrupt\n");