From owner-freebsd-current Sun Jul 21 17: 2:29 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BFB1F37B405 for ; Sun, 21 Jul 2002 17:02:24 -0700 (PDT) Received: from web20902.mail.yahoo.com (web20902.mail.yahoo.com [216.136.226.224]) by mx1.FreeBSD.org (Postfix) with SMTP id ED93743E97 for ; Sun, 21 Jul 2002 17:02:21 -0700 (PDT) (envelope-from bsddiy@yahoo.com) Message-ID: <20020722000211.55864.qmail@web20902.mail.yahoo.com> Received: from [218.108.153.73] by web20902.mail.yahoo.com via HTTP; Sun, 21 Jul 2002 17:02:11 PDT Date: Sun, 21 Jul 2002 17:02:11 -0700 (PDT) From: David Xu Subject: Re: signal handling bug in KSE MIII To: Julian Elischer Cc: freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --- David Xu wrote: > I found signal handling is still broken in CURRENT source. > the following program demostrates the bug is still in kernel: > > #include > #include > > void handler(int sig) > { > signal(SIGTSTP, SIG_DFL); > kill(getpid(), SIGTSTP); > } > > int main() > { > char buf[64]; > > signal(SIGTSTP, handler); > kill(getpid(), SIGTSTP); > printf("input foo:"); > scanf("%63s", buf); > printf("you input:%s\n", buf); > return 0; > } > > when I press CTRL+Z, the program does not suspend and directly exits. > ktrace indicates that the program directly exits in kernel without > calling exit() from program. > I found SA_STOP handling is disabled in issignal(), delayed SIGTSTP > is forgotten by kernel, this is the reason why SIGTSTP signal handling > is broken. at least, one program is affected --- ftp, run ftp > client program, when 'ftp>' prompt appears, pressing CTRL+Z, causes ftp > to exit and do not suspend. patch: > > --- kern_sig.c.old Sun Jul 21 15:38:00 2002 > +++ kern_sig.c Sun Jul 21 16:31:02 2002 > @@ -1657,7 +1657,7 @@ > #endif > break; /* == ignore */ > } > -#if 0 > + > /* > * If there is a pending stop signal to process > * with default action, stop here, > @@ -1679,16 +1679,10 @@ > PROC_UNLOCK(p->p_pptr); > mtx_lock_spin(&sched_lock); > stop(p); > - PROC_UNLOCK(p); > - DROP_GIANT(); > - p->p_stats->p_ru.ru_nivcsw++; > - mi_switch(); > mtx_unlock_spin(&sched_lock); > - PICKUP_GIANT(); > - PROC_LOCK(p); > break; > } else > -#endif > + > if (prop & SA_IGNORE) { > /* > * Except for SIGCONT, shouldn't get here. > > David Xu > OOPS, the extra kill() calling in main() should be removed in demo program, correct source code is: #include #include void handler(int sig) { signal(SIGTSTP, SIG_DFL); kill(getpid(), SIGTSTP); } int main() { char buf[64]; signal(SIGTSTP, handler); printf("input foo:"); scanf("%63s", buf); printf("you input:%s\n", buf); return 0; } David Xu __________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message