From owner-freebsd-questions@FreeBSD.ORG Thu Nov 4 20:43:54 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF76216A4CE for ; Thu, 4 Nov 2004 20:43:53 +0000 (GMT) Received: from mail.broadpark.no (mail.broadpark.no [217.13.4.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1C22743D4C for ; Thu, 4 Nov 2004 20:43:53 +0000 (GMT) (envelope-from henrik.w.lund@broadpark.no) Received: from [10.0.0.3] (52.80-202-129.nextgentel.com [80.202.129.52]) by mail.broadpark.no (Postfix) with ESMTP id 895C6317F; Thu, 4 Nov 2004 21:44:41 +0100 (MET) Message-ID: <418A9487.7020300@broadpark.no> Date: Thu, 04 Nov 2004 21:43:51 +0100 From: Henrik W Lund User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.7.2) Gecko/20041013 X-Accept-Language: no, en-us, en MIME-Version: 1.0 To: m.hauber@mchsi.com References: <200411021855.52247.m.hauber@mchsi.com> <200411031739.23987.m.hauber@mchsi.com> <20041104022551.GA1840@moo.holy.cow> <200411040521.49689.m.hauber@mchsi.com> In-Reply-To: <200411040521.49689.m.hauber@mchsi.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org Subject: Re: blackbox, bbkeys, and .xinit... (solved) --> UNIX behind the scenes X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2004 20:43:54 -0000 Mike Hauber wrote: > On Wednesday 03 November 2004 09:25 pm, Parv proclaimed: > >>in message <200411031739.23987.m.hauber@mchsi.com>, wrote >>Mike Hauber thusly... >> >> >>>I discovered that with the line "blackbox & bbkeys" in >>>the script, the bbscript remains when I exit blackbox, >>>and I have to close bbscript to return to KDM. >> >>... >> >> >>>However, when I login and close bbkeys, then blackbox >>>abruptly closes (apparently a clean kill), and I return >>>to KDM. >> >>That's what you had asked for. Using '&' after a >>command, a shell executes the command in the background. >>Lack of '&' causes the command to be executed in the >>foreground. Try these two commands in a bourne-like >>shell (such as ash (FreeBSD sh), ksh93, bash2, bash3) ... >> >> sleep 15 && date & >> >> sleep 15 && date >> > > > First of all, I get the syntax. However, I do _not_ > understand the apparent dependence between the first and > the second binary (if you don't know what I'm referring to, > then please read the rest of my last email). > > >>In your situation, blackbox runs in the background & >>bbkeys in foreground. If you wanted to run bbkeys only >>if blackbox runs, then do AND operation ... >> >> blackbox && bbkeys >> > > > Actually, no. If I were to put 'blackbox && bbkeys' in the > script, then blackbox would appear, and then _after_ I exit > blackbox bbkeys shows up on the KDM "root" background. > Then when I close bbkeys, the KDM login window is restored. > Vice-versa the other way around. Obviously, this is not > what I'm after. > > I've found the solution (as indicated in my last email), but > again, I don't understand the dependency that the second > binary seems to have on the first (ie. close the second and > the first disappears, but _not_ vice-versa). I haven't > found the dependency documented anywhere, and therefore I > don't understand _why_ it's the solution. > > >>... optionally send the both commands in the background >>(say, if there are more commands to be run after the two >>commands)... >> >> blackbox && bbkeys & >> >> >>See also... >> >> - Get a good introductory Unix book >> >> - Man page for the shell which will execute your .xinit >> >> - Search "Google Groups" at http://groups.google.com/ >>... >> >> + comp.unix.* newsgroups for "foreground background >>process OR command shell" search term >> >> + comp.unix.* & comp.windows.x newsgroups for >>"shell xinitrc OR xsession background" >> >> >> - Parv >> >>-- > > > You're probably right. This is more a NIX question in > general rather than a FreeBSD-specific question. I'll post > it to another board. Thanks. > > Mike Greetings! Consider this: you start a shell script that in turn runs the two commands, right? If you do blackbox & bbkeys this puts blackbox in the background and runs bbkeys in the foreground. Now, if you close blackbox, bbkeys is still running, and thus the shellscript will also keep running (seeing as how the script is the parent process of bbkeys). On the other hand, if you do bbkeys & blackbox this will send bbkeys into the background and keep blackbox in the foreground. Now, when you exit blackbox, the shellscript will have reached the end of its execution (seeing as how all the children for which it has been told to wait have terminated) and will terminate. Being a child process of the script, bbkeys will also terminate as a result of this. I don't know if it's easier to see if I write it out as blacbox& bbkeys vs. bbkeys& blackbox Did this make things more clear? :-) -- Henrik W Lund