Sync with 4.4BSD-Lite2

This commit is contained in:
tls 1996-12-28 07:10:57 +00:00
parent 517427d9e1
commit 19d35cbcd9
14 changed files with 254 additions and 74 deletions

View File

@ -1,5 +1,5 @@
# $NetBSD: Makefile,v 1.9 1996/10/18 06:17:36 thorpej Exp $
# @(#)Makefile 8.2 (Berkeley) 1/25/94
# $NetBSD: Makefile,v 1.10 1996/12/28 07:10:57 tls Exp $
# @(#)Makefile 8.3 (Berkeley) 4/20/95
PROG= mail
SRCS= version.c aux.c cmd1.c cmd2.c cmd3.c cmdtab.c collect.c dotlock.c \

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmd1.c,v 1.5 1996/06/08 19:48:11 christos Exp $ */
/* $NetBSD: cmd1.c,v 1.6 1996/12/28 07:10:58 tls Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmd1.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95";
#else
static char rcsid[] = "$NetBSD: cmd1.c,v 1.5 1996/06/08 19:48:11 christos Exp $";
static char rcsid[] = "$NetBSD: cmd1.c,v 1.6 1996/12/28 07:10:58 tls Exp $";
#endif
#endif /* not lint */
@ -473,3 +473,27 @@ folders(v)
(void) run_command(cmd, 0, -1, -1, dirname, NOSTR, NOSTR);
return 0;
}
/*
* Update the mail file with any new messages that have
* come in since we started reading mail.
*/
int
inc(v)
void *v;
{
int nmsg, mdot;
nmsg = incfile();
if (nmsg == 0) {
printf("No new mail.\n");
} else if (nmsg > 0) {
mdot = newfileinfo(msgCount - nmsg);
dot = &message[mdot - 1];
} else {
printf("\"inc\" command failed...\n");
}
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmd3.c,v 1.5 1996/06/08 19:48:14 christos Exp $ */
/* $NetBSD: cmd3.c,v 1.6 1996/12/28 07:10:59 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmd3.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
#else
static char rcsid[] = "$NetBSD: cmd3.c,v 1.5 1996/06/08 19:48:14 christos Exp $";
static char rcsid[] = "$NetBSD: cmd3.c,v 1.6 1996/12/28 07:10:59 tls Exp $";
#endif
#endif /* not lint */
@ -562,7 +562,7 @@ file(v)
char **argv = v;
if (argv[0] == NOSTR) {
newfileinfo();
newfileinfo(0);
return 0;
}
if (setfile(*argv) < 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmdtab.c,v 1.6 1996/06/08 19:48:15 christos Exp $ */
/* $NetBSD: cmdtab.c,v 1.7 1996/12/28 07:10:59 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)cmdtab.c 8.2 (Berkeley) 4/20/95";
#else
static char rcsid[] = "$NetBSD: cmdtab.c,v 1.6 1996/06/08 19:48:15 christos Exp $";
static char rcsid[] = "$NetBSD: cmdtab.c,v 1.7 1996/12/28 07:10:59 tls Exp $";
#endif
#endif /* not lint */
@ -119,5 +119,6 @@ const struct cmd cmdtab[] = {
{ "core", core, M|NOLIST, 0, 0 },
{ "#", null, M|NOLIST, 0, 0 },
{ "clobber", clobber, M|RAWLIST, 0, 1 },
{ "inc", inc, T|NOLIST, 0, 0 },
{ 0, 0, 0, 0, 0 }
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: def.h,v 1.8 1996/06/08 19:48:18 christos Exp $ */
/* $NetBSD: def.h,v 1.9 1996/12/28 07:11:00 tls Exp $ */
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@ -31,8 +31,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)def.h 8.2 (Berkeley) 3/21/94
* $NetBSD: def.h,v 1.8 1996/06/08 19:48:18 christos Exp $
* @(#)def.h 8.4 (Berkeley) 4/20/95
* $NetBSD: def.h,v 1.9 1996/12/28 07:11:00 tls Exp $
*/
/*
@ -70,10 +70,10 @@
struct message {
short m_flag; /* flags, see below */
short m_block; /* block number of this message */
long m_block; /* block number of this message */
short m_offset; /* offset in block of message */
long m_size; /* Bytes in the message */
short m_lines; /* Lines in the message */
long m_lines; /* Lines in the message */
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.4 1996/06/08 19:48:21 christos Exp $ */
/* $NetBSD: extern.h,v 1.5 1996/12/28 07:11:01 tls Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -32,8 +32,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)extern.h 8.1 (Berkeley) 6/6/93
* $NetBSD: extern.h,v 1.4 1996/06/08 19:48:21 christos Exp $
* @(#)extern.h 8.2 (Berkeley) 4/20/95
* $NetBSD: extern.h,v 1.5 1996/12/28 07:11:01 tls Exp $
*/
struct name;
@ -157,6 +157,7 @@ struct ignoretab;
int ignore1 __P((char *[], struct ignoretab *, char *));
int igshow __P((struct ignoretab *, char *));
void intr __P((int));
int inc __P((void *));
int isdate __P((char []));
int isdir __P((char []));
int isfileaddr __P((char *));
@ -172,7 +173,7 @@ struct var *
int mail __P((struct name *,
struct name *, struct name *, struct name *, char *));
void mail1 __P((struct header *, int));
void makemessage __P((FILE *));
void makemessage __P((FILE *, int));
void mark __P((int));
int markall __P((char [], int));
int matchsender __P((char *, int));
@ -184,7 +185,7 @@ void mespipe __P((FILE *, char []));
int messize __P((void *));
int metamess __P((int, int));
int more __P((void *));
int newfileinfo __P((void));
int newfileinfo __P((int));
int next __P((void *));
int null __P((void *));
void panic __P((const char *, ...))
@ -229,7 +230,7 @@ int sendmail __P((void *));
int set __P((void *));
int setfile __P((char *));
void setmsize __P((int));
void setptr __P((FILE *));
void setptr __P((FILE *, off_t));
void setscreensize __P((void));
int shell __P((void *));
void sigchild __P((int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: fio.c,v 1.5 1996/06/08 19:48:22 christos Exp $ */
/* $NetBSD: fio.c,v 1.6 1996/12/28 07:11:02 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)fio.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
static char rcsid[] = "$NetBSD: fio.c,v 1.5 1996/06/08 19:48:22 christos Exp $";
static char rcsid[] = "$NetBSD: fio.c,v 1.6 1996/12/28 07:11:02 tls Exp $";
#endif
#endif /* not lint */
@ -60,17 +60,18 @@ static char rcsid[] = "$NetBSD: fio.c,v 1.5 1996/06/08 19:48:22 christos Exp $";
* Set up the input pointers while copying the mail file into /tmp.
*/
void
setptr(ibuf)
setptr(ibuf, offset)
register FILE *ibuf;
off_t offset;
{
extern char *tmpdir;
register int c, count;
register char *cp, *cp2;
struct message this;
FILE *mestmp;
off_t offset;
int maybe, inhead;
char linebuf[LINESIZE];
int omsgCount;
/* Get temporary file. */
(void)sprintf(linebuf, "%s/mail.XXXXXX", tmpdir);
@ -81,10 +82,23 @@ setptr(ibuf)
}
(void)unlink(linebuf);
msgCount = 0;
if (offset == 0) {
msgCount = 0;
} else {
/* Seek into the file to get to the new messages */
(void) fseek(ibuf, offset, 0);
/*
* We need to make "offset" a pointer to the end of
* the temp file that has the copy of the mail file.
* If any messages have been edited, this will be
* different from the offset into the mail file.
*/
(void) fseek(otf, 0L, 2);
offset = ftell(otf);
}
omsgCount = msgCount;
maybe = 1;
inhead = 0;
offset = 0;
this.m_flag = MUSED|MNEW;
this.m_size = 0;
this.m_lines = 0;
@ -96,7 +110,7 @@ setptr(ibuf)
perror("temporary file");
exit(1);
}
makemessage(mestmp);
makemessage(mestmp, omsgCount);
return;
}
count = strlen(linebuf);
@ -210,20 +224,28 @@ setinput(mp)
* a dynamically allocated message structure.
*/
void
makemessage(f)
makemessage(f, omsgCount)
FILE *f;
int omsgCount;
{
register size = (msgCount + 1) * sizeof (struct message);
if (message != 0)
free((char *) message);
if ((message = (struct message *) malloc((unsigned) size)) == 0)
panic("Insufficient memory for %d messages", msgCount);
dot = message;
size -= sizeof (struct message);
if (omsgCount) {
message = (struct message *)realloc(message, (unsigned) size);
if (message == 0)
panic("Insufficient memory for %d messages\n",
msgCount);
} else {
if (message != 0)
free((char *) message);
if ((message = (struct message *) malloc((unsigned) size)) == 0)
panic("Insufficient memory for %d messages", msgCount);
dot = message;
}
size -= (omsgCount + 1) * sizeof (struct message);
fflush(f);
(void) lseek(fileno(f), (off_t)sizeof *message, 0);
if (read(fileno(f), (char *) message, size) != size)
if (read(fileno(f), (char *) &message[omsgCount], size) != size)
panic("Message temporary file corrupted");
message[msgCount].m_size = 0;
message[msgCount].m_lines = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: head.c,v 1.5 1996/06/08 19:48:26 christos Exp $ */
/* $NetBSD: head.c,v 1.6 1996/12/28 07:11:03 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)head.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)head.c 8.2 (Berkeley) 4/20/95";
#else
static char rcsid[] = "$NetBSD: head.c,v 1.5 1996/06/08 19:48:26 christos Exp $";
static char rcsid[] = "$NetBSD: head.c,v 1.6 1996/12/28 07:11:03 tls Exp $";
#endif
#endif /* not lint */
@ -169,18 +169,18 @@ copyin(src, space)
* 'N' A new line
*/
char ctype[] = "Aaa Aaa O0 00:00:00 0000";
char ctype_without_secs[] = "Aaa Aaa O0 00:00 0000";
char SysV_ctype[] = "Aaa Aaa O0 00:00 0000";
char tmztype[] = "Aaa Aaa O0 00:00:00 AAA 0000";
char tmztype_without_secs[] = "Aaa Aaa O0 00:00 AAA 0000";
char SysV_tmztype[] = "Aaa Aaa O0 00:00 AAA 0000";
int
isdate(date)
char date[];
{
return cmatch(date, ctype_without_secs) ||
cmatch(date, tmztype_without_secs) ||
cmatch(date, ctype) || cmatch(date, tmztype);
return cmatch(date, ctype) ||
cmatch(date, tmztype) ||
cmatch(date, SysV_tmztype) || cmatch(date, SysV_ctype);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: lex.c,v 1.7 1996/06/08 19:48:28 christos Exp $ */
/* $NetBSD: lex.c,v 1.8 1996/12/28 07:11:04 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95";
#else
static char rcsid[] = "$NetBSD: lex.c,v 1.7 1996/06/08 19:48:28 christos Exp $";
static char rcsid[] = "$NetBSD: lex.c,v 1.8 1996/12/28 07:11:04 tls Exp $";
#endif
#endif /* not lint */
@ -148,8 +148,14 @@ setfile(name)
}
(void) fcntl(fileno(itf), F_SETFD, 1);
rm(tempMesg);
setptr(ibuf);
setptr(ibuf, 0);
setmsize(msgCount);
/*
* New mail mail have arrived while we were reading
* up the mail file, so reset mailsize to be where
* we really are in the file...
*/
mailsize = ftell(ibuf);
Fclose(ibuf);
relsesigs();
sawcom = 0;
@ -161,6 +167,36 @@ nomail:
return(0);
}
/*
* Incorporate any new mail that has arrived since we first
* started reading mail.
*/
int
incfile()
{
int newsize;
int omsgCount = msgCount;
FILE *ibuf;
ibuf = Fopen(mailname, "r");
if (ibuf == NULL)
return -1;
holdsigs();
newsize = fsize(ibuf);
if (newsize == 0)
return -1; /* mail box is now empty??? */
if (newsize < mailsize)
return -1; /* mail box has shrunk??? */
if (newsize == mailsize)
return 0; /* no new mail */
setptr(ibuf, mailsize);
setmsize(msgCount);
mailsize = ftell(ibuf);
Fclose(ibuf);
relsesigs();
return(msgCount - omsgCount);
}
int *msgvec;
int reset_on_stop; /* do a reset() if stopped */
@ -195,6 +231,8 @@ commands()
* string space, and flush the output.
*/
if (!sourcing && value("interactive") != NOSTR) {
if ((value("autoinc") != NOSTR) && (incfile() > 0))
printf("New mail has arrived.\n");
reset_on_stop = 1;
printf(prompt);
}
@ -570,7 +608,7 @@ announce()
{
int vec[2], mdot;
mdot = newfileinfo();
mdot = newfileinfo(0);
vec[0] = mdot;
vec[1] = 0;
dot = &message[mdot - 1];
@ -586,23 +624,24 @@ announce()
* Return a likely place to set dot.
*/
int
newfileinfo()
newfileinfo(omsgCount)
int omsgCount;
{
register struct message *mp;
register int u, n, mdot, d, s;
char fname[BUFSIZ], zname[BUFSIZ], *ename;
for (mp = &message[0]; mp < &message[msgCount]; mp++)
for (mp = &message[omsgCount]; mp < &message[msgCount]; mp++)
if (mp->m_flag & MNEW)
break;
if (mp >= &message[msgCount])
for (mp = &message[0]; mp < &message[msgCount]; mp++)
for (mp = &message[omsgCount]; mp < &message[msgCount]; mp++)
if ((mp->m_flag & MREAD) == 0)
break;
if (mp < &message[msgCount])
mdot = mp - &message[0] + 1;
else
mdot = 1;
mdot = omsgCount + 1;
s = d = 0;
for (mp = &message[0], n = 0, u = 0; mp < &message[msgCount]; mp++) {
if (mp->m_flag & MNEW)

View File

@ -1,4 +1,4 @@
/* $NetBSD: list.c,v 1.4 1996/06/08 19:48:30 christos Exp $ */
/* $NetBSD: list.c,v 1.5 1996/12/28 07:11:05 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)list.c 8.2 (Berkeley) 4/19/94";
static char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95";
#else
static char rcsid[] = "$NetBSD: list.c,v 1.4 1996/06/08 19:48:30 christos Exp $";
static char rcsid[] = "$NetBSD: list.c,v 1.5 1996/12/28 07:11:05 tls Exp $";
#endif
#endif /* not lint */
@ -676,6 +676,46 @@ matchsender(str, mesg)
return(*cp == 0);
}
/*
* See if the passed name received the passed message number. Return true
* if so.
*/
static char *to_fields[] = { "to", "cc", "bcc", 0 };
matchto(str, mesg)
char *str;
{
register struct message *mp;
register char *cp, *cp2, *backup, **to;
str++;
if (*str == 0) /* null string matches nothing instead of everything */
return(0);
mp = &message[mesg-1];
for (to = to_fields; *to; to++) {
cp = str;
cp2 = hfield(*to, mp);
if (cp2 != NOSTR) {
backup = cp2;
while (*cp2) {
if (*cp == 0)
return(1);
if (raise(*cp++) != raise(*cp2++)) {
cp2 = ++backup;
cp = str;
}
}
if (*cp == 0)
return(1);
}
}
return(0);
}
/*
* See if the given string matches inside the subject field of the
* given message. For the purpose of the scan, we ignore case differences.
@ -705,8 +745,12 @@ matchsubj(str, mesg)
*/
if (value("searchheaders") && (cp = index(str, ':'))) {
/* Check for special case "/To:" */
if (raise(str[0]) == 'T' && raise(str[1]) == 'O' &&
str[2] == ':')
return(matchto(cp, mesg));
*cp++ = '\0';
cp2 = hfield(str, mp);
cp2 = hfield(*str ? str : "subject", mp);
cp[-1] = ':';
str = cp;
} else {

View File

@ -29,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)mail.1 8.2 (Berkeley) 12/30/93
.\" $Id: mail.1,v 1.5 1994/06/29 05:09:32 deraadt Exp $
.\" from: @(#)mail.1 8.8 (Berkeley) 4/28/95
.\" $Id: mail.1,v 1.6 1996/12/28 07:11:06 tls Exp $
.\"
.Dd December 30, 1993
.Dd April 28, 1995
.Dt MAIL 1
.Os BSD 4
.Sh NAME
@ -447,6 +447,7 @@ argument is given, the previous 18\-message group is printed.
.It Ic help
A synonym for
.Ic \&?
.ne li
.It Ic hold
.Pf ( Ic ho ,
also
@ -472,6 +473,13 @@ and
.Ic Print
commands can be used to print a message in its entirety, including
ignored fields.
.It Ic inc
Incorporate any new messages that have arrived while mail
is being read.
The new messages are added to the end of the message list,
and the current message is reset to be the first new mail message.
This does not renumber the existing message list, nor does
does it cause any changes made so far to be saved.
If
.Ic ignore
is executed with no arguments, it lists the current set of
@ -585,6 +593,7 @@ saving a message by
.Ic save
or when automatically saving to
.Ar mbox .
.pl +1
.It Ic saveretain
.Ic Saveretain
is to
@ -712,6 +721,7 @@ Message headers currently being ignored (by the
or
.Ic retain
command) are not included.
.ne li
.It Ic \&~F Ns Ar messages
Identical to
.Ic \&~f ,
@ -803,11 +813,18 @@ Causes
to prompt you for the subject of each message you send.
If
you respond with simply a newline, no subject field will be sent.
.ne li
.It Ar askcc
Causes you to be prompted for additional carbon copy recipients at the
end of each message.
Responding with a newline indicates your
satisfaction with the current list.
.It Ar autoinc
Causes new mail to be automatically incorporated when it arrives.
Setting this is similar to issuing the
.Ic inc
command at each prompt, except that the current message is not
reset when new mail arrives.
.It Ar askbcc
Causes you to be prompted for additional blind carbon copy recipients at the
end of each message.
@ -888,6 +905,13 @@ Suppresses the printing of the version when first invoked.
If this option is set, then a message-list specifier in the form ``/x:y''
will expand to all messages containing the substring ``y'' in the header
field ``x''. The string search is case insensitive.
If ``x'' is ommitted, it will default to the ``Subject'' header field.
The form ``/to:y'' is a special case, and will expand
to all messages containing the substring ``y'' in the ``To'', ``Cc''
or ``Bcc'' header fields.
The check for "to" is case sensitive, so that
``/To:y'' can be used to limit the search for ``y'' to just
the ``To:'' field.
.It Ar verbose
Setting the option
.Ar verbose
@ -936,6 +960,7 @@ Pathname of the text editor to use in the
command and
.Ic \&~v
escape.
.ne li
.It Va crt
The valued option
.Va crt
@ -997,6 +1022,9 @@ Post office.
User's old mail.
.It ~/.mailrc
File giving initial mail commands.
This can be overridden by setting the
.Ev MAILRC
environment variable.
.It Pa /tmp/R*
Temporary files.
.It Pa /usr/share/misc/mail.*help

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.5 1996/06/08 19:48:31 christos Exp $ */
/* $NetBSD: main.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -41,9 +41,9 @@ static char copyright[] =
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/20/95";
#else
static char rcsid[] = "$NetBSD: main.c,v 1.5 1996/06/08 19:48:31 christos Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.6 1996/12/28 07:11:07 tls Exp $";
#endif
#endif /* not lint */
@ -71,6 +71,7 @@ main(argc, argv)
char *ef;
char nosrc = 0;
sig_t prevint;
char *rc;
/*
* Set up a reasonable environment.
@ -218,7 +219,9 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
* Expand returns a savestr, but load only uses the file name
* for fopen, so it's safe to do this.
*/
load(expand("~/.mailrc"));
if ((rc = getenv("MAILRC")) == 0)
rc = "~/.mailrc";
load(expand(rc));
if (!rcvmode) {
mail(to, cc, bcc, smopts, subject);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: quit.c,v 1.5 1996/06/08 19:48:37 christos Exp $ */
/* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)quit.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95";
#else
static char rcsid[] = "$NetBSD: quit.c,v 1.5 1996/06/08 19:48:37 christos Exp $";
static char rcsid[] = "$NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $";
#endif
#endif /* not lint */
@ -288,8 +288,8 @@ nolock:
c = getc(ibuf);
}
Fclose(ibuf);
fflush(obuf);
}
fflush(obuf);
trunc(obuf);
if (ferror(obuf)) {
perror(mbox);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty.c,v 1.5 1996/06/08 19:48:43 christos Exp $ */
/* $NetBSD: tty.c,v 1.6 1996/12/28 07:11:08 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@ -35,9 +35,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: tty.c,v 1.5 1996/06/08 19:48:43 christos Exp $";
static char rcsid[] = "$NetBSD: tty.c,v 1.6 1996/12/28 07:11:08 tls Exp $";
#endif
#endif /* not lint */
@ -72,6 +72,8 @@ grabh(hp, gflags)
sig_t saveint;
#ifndef TIOCSTI
sig_t savequit;
#else
int extproc, flag;
#endif
sig_t savetstp;
sig_t savettou;
@ -103,6 +105,14 @@ grabh(hp, gflags)
if ((savequit = signal(SIGQUIT, SIG_IGN)) == SIG_DFL)
signal(SIGQUIT, SIG_DFL);
#else
# ifdef TIOCEXT
extproc = ((ttybuf.c_lflag & EXTPROC) ? 1 : 0);
if (extproc) {
flag = 0;
if (ioctl(fileno(stdin), TIOCEXT, &flag) < 0)
perror("TIOCEXT: off");
}
# endif /* TIOCEXT */
if (setjmp(intjmp))
goto out;
saveint = signal(SIGINT, ttyint);
@ -148,6 +158,14 @@ out:
if (ttyset)
tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf);
signal(SIGQUIT, savequit);
#else
# ifdef TIOCEXT
if (extproc) {
flag = 1;
if (ioctl(fileno(stdin), TIOCEXT, &flag) < 0)
perror("TIOCEXT: on");
}
# endif /* TIOCEXT */
#endif
signal(SIGINT, saveint);
return(errs);