I found signal handling is still broken in CURRENT source.
the following program demostrates the bug is still in kernel:

#include <stdio.h>
#include <signal.h>

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


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to