Skip to content
Browse files

Remove SIGURG handling and replace with a call to select.

Solves the lockup on ctrl-c bug for Solaris and improve code readability.


git-svn-id: svn://anonsvn.mit.edu/krb5/branches/hartmans_pty_utmp@7332 dc483132-0cff-0310-8789-dd5450dbe970
  • Loading branch information...
1 parent b38ac4a commit 16d87aa71349a0e0efe6a9fca459af9065d48bc4 hartmans committed Jan 17, 1996
Showing with 20 additions and 103 deletions.
  1. +2 −1 src/appl/bsd/ChangeLog
  2. +18 −102 src/appl/bsd/krlogin.c
View
3 src/appl/bsd/ChangeLog
@@ -2,7 +2,8 @@ Wed Jan 17 15:14:33 1996 Sam Hartman <hartmans@tertius.mit.edu>
* krlogin.c ((reader): Use select to find out-of-band data, not signals.
(oob): No longer a signal handler; just a function.
-
+ (writer): get rid of copytochild setup as sigurg no longer needed
+ (main): Don't block SIGURG
* configure.in : Include sys/time.h check
Mon Jan 15 16:16:07 1996 Sam Hartman <hartmans@tertius.mit.edu>
View
120 src/appl/bsd/krlogin.c
@@ -222,7 +222,8 @@ struct winsize winsize;
char *host=0; /* external, so it can be
reached from confirm_death() */
-krb5_sigtype sigwinch KRB5_PROTOTYPE((int)), oob KRB5_PROTOTYPE((int));
+krb5_sigtype sigwinch KRB5_PROTOTYPE((int));
+void oob KRB5_PROTOTYPE((void));
krb5_sigtype lostpeer KRB5_PROTOTYPE((int));
#if __STDC__
int setsignal(int sig, krb5_sigtype (*act)());
@@ -550,16 +551,15 @@ main(argc, argv)
(void) sigaction(SIGPIPE, &sa, (struct sigaction *)0);
(void) sigemptyset(&urgmask);
- (void) sigaddset(&urgmask, SIGURG);
(void) sigaddset(&urgmask, SIGUSR1);
oldmask = &omask;
(void) sigprocmask(SIG_BLOCK, &urgmask, oldmask);
#else
(void) signal(SIGPIPE, lostpeer);
#ifdef sgi
- oldmask = sigignore(sigmask(SIGURG) | sigmask(SIGUSR1));
+ oldmask = sigignore( sigmask(SIGUSR1));
#else
- oldmask = sigblock(sigmask(SIGURG) | sigmask(SIGUSR1));
+ oldmask = sigblock( sigmask(SIGUSR1));
#endif
#endif /* POSIX_SIGNALS */
@@ -609,28 +609,6 @@ main(argc, argv)
if (rem < 0)
exit(1);
- /* we need to do the SETOWN here so that we get the SIGURG
- registered if the URG data come in early, before the reader() gets
- to do this for real (otherwise, the signal is never generated
- by the kernel). We block it above, so when it gets unblocked
- it will get processed by the reader().
- There is a possibility that the signal will get delivered to both
- writer and reader, but that is harmless, since the writer reflects
- it to the reader, and the oob() processing code in the reader will
- work properly even if it is called when no oob() data is present.
- */
-#ifdef hpux
- /* hpux invention */
- {
- int pid = getpid();
- ioctl(rem, FIOSSAIOSTAT, &pid); /* trick: pid is non-zero */
- ioctl(rem, FIOSSAIOOWN, &pid);
- }
-#else
-#if 0
- (void) fcntl(rem, F_SETOWN, getpid());
-#endif
-#endif
if (options & SO_DEBUG &&
setsockopt(rem, SOL_SOCKET, SO_DEBUG, (char*)&on, sizeof (on)) < 0)
perror("rlogin: setsockopt (SO_DEBUG)");
@@ -688,8 +666,7 @@ int confirm_death ()
int child;
krb5_sigtype catchild KRB5_PROTOTYPE((int));
-krb5_sigtype copytochild KRB5_PROTOTYPE((int)),
- writeroob KRB5_PROTOTYPE((int));
+krb5_sigtype writeroob KRB5_PROTOTYPE((int));
int defflags, tabflag;
int deflflags;
@@ -816,16 +793,8 @@ doit(oldmask)
exit(3);
}
- /*
- * We may still own the socket, and may have a pending SIGURG
- * (or might receive one soon) that we really want to send to
- * the reader. Set a trap that simply copies such signals to
- * the child.
- */
#ifdef POSIX_SIGNALS
/* "sa" has already been initialized above. */
- sa.sa_handler = copytochild;
- (void) sigaction(SIGURG, &sa, (struct sigaction *)0);
sa.sa_handler = writeroob;
(void) sigaction(SIGUSR1, &sa, (struct sigaction *)0);
@@ -835,7 +804,6 @@ doit(oldmask)
sa.sa_handler = catchild;
(void) sigaction(SIGCHLD, &sa, (struct sigaction *)0);
#else
- (void) signal(SIGURG, copytochild);
(void) signal(SIGUSR1, writeroob);
#ifndef sgi
(void) sigsetmask(oldmask);
@@ -927,15 +895,6 @@ done(status)
-/*
- * Copy SIGURGs to the child process.
- */
-krb5_sigtype
- copytochild(signo)
-int signo;
-{
- (void) kill(child, SIGURG);
-}
@@ -1234,11 +1193,6 @@ int rcvcnt;
int rcvstate;
int ppid;
-#ifdef POSIX_SETJMP
-sigjmp_buf rcvtop;
-#else
-jmp_buf rcvtop;
-#endif
void oob()
{
@@ -1257,42 +1211,9 @@ void oob()
struct sgttyb sb;
#endif
#endif
- fd_set remset;
- struct timeval tv;
- tv.tv_usec = 10000;
- tv.tv_sec = 0;
- FD_ZERO(&remset);
- FD_SET(rem, &remset);
-mark = 0;
- /* If we don't have OOB data yet,
- * see if our buffer is full and drain it. */
+ mark = 0;
- while (recv(rem, &mark, 1, MSG_OOB) < 0)
- switch (errno) {
-
- case EWOULDBLOCK:
- /*
- * Urgent data not here yet.
- * It may not be possible to send it yet
- * if we are blocked for output
- * and our input buffer is full.
- */
- if (rcvcnt < sizeof(rcvbuf)) {
- n = read(rem, rcvbuf + rcvcnt,
- sizeof(rcvbuf) - rcvcnt);
- if (n <= 0)
- return;
- rcvd += n;
- } else {
- n = read(rem, waste, sizeof(waste));
- if (n <= 0)
- return;
- }
- continue;
-
- default:
- return;
- }
+ recv(rem, &mark, 1, MSG_OOB);
if (mark & TIOCPKT_WINDOW) {
/*
* Let server know about window size changes
@@ -1360,20 +1281,8 @@ mark = 0;
n = read(rem, waste, sizeof (waste));
if (n <= 0)
break;
+return;
}
- /*
- * Don't want any pending data to be output,
- * so clear the recv buffer.
- * If we were hanging on a write when interrupted,
- * don't want it to restart. If we were reading,
- * restart anyway.
- */
- rcvcnt = 0;
-#ifdef POSIX_SETJMP
- siglongjmp(rcvtop, 1);
-#else
- longjmp(rcvtop, 1);
-#endif
}
@@ -1415,6 +1324,13 @@ fd_set readset, excset;
ppid = getppid();
FD_ZERO(&readset);
FD_ZERO(&excset);
+#ifdef POSIX_SIGNALS
+ sigprocmask(SIG_SETMASK, oldmask, (sigset_t*)0);
+#else
+#ifndef sgi
+ (void) sigsetmask(oldmask);
+#endif
+#endif /* POSIX_SIGNALS */
for (;;) {
while ((remaining = rcvcnt - (bufp - rcvbuf)) > 0) {
@@ -1430,12 +1346,12 @@ FD_ZERO(&readset);
bufp = rcvbuf;
rcvcnt = 0;
rcvstate = READING;
-FD_set(rem,&readset);
+FD_SET(rem,&readset);
FD_SET(rem,&excset);
if (select(rem+1, &readset, 0, &excset, 0) > 0 ) {
-if (FD_ISET(rem, &excset))
+if (FD_ISSET(rem, &excset))
oob();
-if (FD_ISET(rem, &readset)) {
+if (FD_ISSET(rem, &readset)) {
rcvcnt = des_read(rem, rcvbuf, sizeof (rcvbuf));
if (rcvcnt == 0)
return (0);

0 comments on commit 16d87aa

Please sign in to comment.
Something went wrong with that request. Please try again.