Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Aug 2002 18:54:42 -0700
From:      Julian Elischer <julian@elischer.org>
To:        David Xu <bsddiy@yahoo.com>
Cc:        "Andrey A. Chernov" <ache@nagual.pp.ru>, current@freebsd.org
Subject:   Re: cvs commit: src/sys/kern kern_sig.c (fwd)
Message-ID:  <3D571562.B7CDC954@elischer.org>
References:  <20020811132854.99343.qmail@web20907.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
I am forwarding this to -current as I think it needs more neurons on it..
I am presently unable to spend any due to work commitments, and due to a sort-of 
personal confusion about tis stuff anyhow..


David Xu wrote:
> 
> does anyone believe that su behaviours correctly?
> we are talking that kernel has bug to handle job control
> but I found that the issue may not related to signal handling
> problem, but related to su or csh's job control.
> I see this piece of code in su.c:
> 
> switch (child_pid) {
>         default:
>                 while ((ret_pid = waitpid(child_pid, &statusp, WUNTRACED)) != eca-1) {
>                         if (WIFSTOPPED(statusp)) {
>                                 child_pgrp = tcgetpgrp(1);
>                                 kill(getpid(), SIGSTOP);
>                                 tcsetpgrp(1, child_pgrp);
>                                 kill(child_pid, SIGCONT);
>                                 statusp = 1;
>                                 continue;
>                         }
>                         break;
>                 }
> 
> I have traced down su. In my test, the su process forked a
> child process, child process pid is 873 while parent pid is 872.
> these code are in question, I found that tcgetpgrp(1) really
> returns parent su pid, it is 872, parent su process
> then suspends itself until login shell unsuspends it,
> when it resumes, I have inserted another tcgetpgrp(1) after it resumes,
> and found that it was 873, it was child su process pid! not 872,
> because parent su was not in foreground group, when it called tcsetpgrp(1, 872),
> it got a SIGTTOU and suspended there, the SIGCONT was not sent out.
> so the code's behaviour is not what the author's want, and all job
> control gets weird. I suguest this job control assumption should be removed,
> strange thing is why su calls fork()? why doesn't call directly execvl()?
> I don't see su calls fork() in OpenBSD.
> 
> --- "Andrey A. Chernov" <ache@nagual.pp.ru> wrote:
> > On Sat, Aug 10, 2002 at 13:36:32 +0400, Andrey A. Chernov wrote:
> > > On Fri, Aug 09, 2002 at 18:23:05 -0700, Julian Elischer wrote:
> > > >
> > > > Andrey.. we need you to also ktrace the child as well..
> > > > (together with the su)  use ktrace -d -i {YOURSHELL}
> > > > to capture everything...
> > > >
> > >
> > > Here it is (starting from the moment, when su exec'ed)
> >
> > I notice that no 'su' section here, it because that su have s-bit and not
> > traced. I try to do the same thing from root and get very strange
> > behaviour, summarized in the following table:
> >
> > -----------------------------------------
> > root login csh> su
> > suspend
> > fg
> > (got bug)
> > -----------------------------------------
> > root login csh> ktrace -d -i /bin/csh
> > su
> > suspend
> > fg
> > (NO BUG!!!!)
> > -----------------------------------------
> > user login csh> su
> > suspend
> > fg
> > (got bug)
> > -----------------------------------------
> > user login csh> ktrace -d -i /bin/csh
> > su
> > suspend
> > fg
> > (got bug)
> >
> > It means I can't ktrace _both_ csh and su in the same time, since bug
> > dissapearse just for that variant.
> >
> > --
> > Andrey A. Chernov
> > http://ache.pp.ru/
> 
> __________________________________________________
> Do You Yahoo!?
> HotJobs - Search Thousands of New Jobs
> http://www.hotjobs.com

-- 
+------------------------------------+       ______ _  __
|   __--_|\  Julian Elischer         |       \     U \/ / hard at work in 
|  /       \ julian@elischer.org     +------>x   USA    \ a very strange
| (   OZ    )                                \___   ___ | country !
+- X_.---._/    presently in San Francisco       \_/   \\
          v

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D571562.B7CDC954>