From owner-freebsd-current Sun Aug 11 18:57:35 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 ACC8A37B400 for ; Sun, 11 Aug 2002 18:57:30 -0700 (PDT) Received: from mta5.rcsntx.swbell.net (mta5.rcsntx.swbell.net [151.164.30.29]) by mx1.FreeBSD.org (Postfix) with ESMTP id 431EA43E70 for ; Sun, 11 Aug 2002 18:57:30 -0700 (PDT) (envelope-from julian@elischer.org) Received: from elischer.org ([64.164.11.208]) by mta5.rcsntx.swbell.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0H0P0095UK3SKP@mta5.rcsntx.swbell.net> for current@freebsd.org; Sun, 11 Aug 2002 20:57:30 -0500 (CDT) Date: Sun, 11 Aug 2002 18:54:42 -0700 From: Julian Elischer Subject: Re: cvs commit: src/sys/kern kern_sig.c (fwd) To: David Xu Cc: "Andrey A. Chernov" , current@freebsd.org Message-id: <3D571562.B7CDC954@elischer.org> MIME-version: 1.0 X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Accept-Language: en, hu References: <20020811132854.99343.qmail@web20907.mail.yahoo.com> 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 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" 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