--- "Andrey A. Chernov" <[EMAIL PROTECTED]> wrote:
> On Sun, Aug 11, 2002 at 17:41:20 +0400, Andrey A. Chernov wrote:
> > On Sun, Aug 11, 2002 at 06:28:54 -0700, David Xu wrote:
> > > does anyone believe that su behaviours correctly?
> > 
> > I not believe in that first, so why I remove tcsetpgrg() in my initial 
> > commit. It fix suspend/fg, but break stop $$/fg those times. I not test, 
> > is it break stop $$/fg now too (I'll do it a bit later and send result).
> > fork/wait seems to be needed here just for PAM_END.
> Yes, still there. If tcsetpgrp() removed, suspend/fg fixed, but "stop
> $$/fg" kills login shell. It means that neither variant is correct, unless
> there is a kernel bug. To be 100% sure, we need to test su with old
> -current kernel without KSE. Anybody have that thing? I can cvsup early
> kernel sources and build from them, but I don't know exact KSE changes
> data. Other way is to build su statically and test on -stable. I don't 
> have any -stable machines around.
> -- 
> Andrey A. Chernov
> http://ache.pp.ru/

Sorry, Andrey, current su's job control mode does not work under STABLE too,
I have tested, it has same result as under CURRENT. the following piece of 
code does not work under STABLE, it mimics what su is doing in CURRENT 
source tree.

#include <err.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>

int main()
        pid_t ret_pid, statusp, child_pid, child_pgrp;
        struct sigaction sa, sa_int, sa_quit, sa_tstp;
        char buf[64];
        char* sargv[3];

        sa.sa_flags = SA_RESTART;
        sa.__sigaction_u.__sa_handler = SIG_IGN;
        sigaction(SIGINT, &sa, &sa_int);
        sigaction(SIGQUIT, &sa, &sa_quit);
        sigaction(SIGTSTP, &sa, &sa_tstp);

        child_pid = fork();
        switch (child_pid) {
                while ((ret_pid = waitpid(child_pid, &statusp, WUNTRACED)) != -1) {
                        if (WIFSTOPPED(statusp)) {
                                child_pgrp = tcgetpgrp(1);
                                kill(getpid(), SIGSTOP);
                                tcsetpgrp(1, child_pgrp);
                                kill(child_pid, SIGCONT);
                                statusp = 1;
                if (ret_pid == -1)
                        err(1, "waitpid");
        case -1:
                err(1, "fork");
        case 0:
                sigaction(SIGINT, &sa_int, NULL);
                sigaction(SIGQUIT, &sa_quit, NULL);
                sigaction(SIGTSTP, &sa_tstp, NULL);
                sargv[0] = "csh";
                sargv[1] = NULL;
                execv("/bin/csh", sargv);
                printf("hi, there!\n");
        return 0;


Do You Yahoo!?
HotJobs - Search Thousands of New Jobs

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

Reply via email to