Re: Multiple X Sessions on OSR 6

From: Jean-Pierre Radley (jpr_at_jpr.com)
Date: 10/20/05


Date: 19 Oct 2005 22:12:36 -0400

Bob Stockler typed (on Wed, Oct 19, 2005 at 08:26:02PM -0400):
| Bob Stockler wrote (on Wed, Oct 19, 2005 at 04:25:03PM -0400):
|
| | Roger Cornelius wrote (on Wed, Oct 19, 2005 at 11:37:41AM -0700):
| |
| | | That does eliminate the problems in my script, but at the expense of
| | | forking two additional processes (mine forks none). Can you do it
| | | without the additional processes (this IS meant to be a challenge :))?
| |
| | I'll have a look at using the .X?-lock files in /tmp and do it
| | all in the KornShell (even if I have to resort to ksh93).
| [much snipped above]
|
| Challenge accepted (no resort to ksh93 required).
|
| How does this look to you?
|
| #!/bin/ksh
| # @(#) xstart - Start X using the lowest unused session number.
| integer i j ; cd /tmp ; set -A xs .X*-lock ; cd -
| for i in 0 1 2 3 4 5 6 7 8 9
| do session=${xs[$i]} ; session=${session#".X"}
| session=${session%"-lock"} ; j=$session
| (( i != j )) && {
| echo "exec /usr/bin/startx -- :$i"
| exec /usr/bin/startx -- :$i
| }
| done
|
| Bob (who does his best work after cocktail hour begins)
|
| PS - I use a memory /tmp, so it gets removed after a reboot,
| and experimentation shows the ".X?-lock" files in it get
| removed if an X session is terminated. Others would have
| to maybe remove the .X*-lock files on reboot. I donno.

Terrific script, Bob!

I should think that going further along the the march of the clock,
after a nightcap or two you could readily integrate your code into the
existing /bin/startx and we'll fork yet one less process!

-- 
JP

Quantcast