From: Keith R. J. W. <kr...@op...> - 2003-04-21 21:12:47
|
Quick fix for all of this is to have stdout sent to /dev/null by either using the attached patch or by doing an exec 1>/dev/null in the startx script. Some comments to try to explain things: When ROX-Session is started via some X display manager (xdm, for example), ROX-Session and its children will wind up within the same ``session'' (see getsid(2) and _Advanaced Progamming in the UNIX Environment_, W. Richard Stevens) as the display manager. This is ideal and what we want. There is no controlling terminal within the session (the session leader, xdm in this case, does not have a controlling terminal and thus no process in the session does); stdin is not connected to a terminal. xdm also closes stdout for its children. Things like rox `which vim` do not blow up under xdm. :) xdm also has stderr sent to a file (~/.xsession-errors) rather than to a terminal. The above situation also holds for folks who start X on the console, and then log out of the console. Logging out of the console makes login, the session leader, go away, hence there is no way to read/write std{in,out,err}. ROX-Session will display an error about failing to write to stderr the next time it tries to do so (a properly written startx script should have stderr redirected to a file to avoid such things; furthermore, it should have stdout sent to /dev/null!) When ROX-Session is started via xinit from the linux console (by startx, etc), it winds up in the session of the login process on that terminal. Naturally there is a controlling terminal in this case. So we could use the ioctl here to remove ourselves from that controlling terminal. I have no idea how portable or not portable this is. However it is not enough to remove the controlling terminal (which we'd have to do in ROX-Filer as well, since not all people use ROX-Session). We'd also have to close (or redirect to /dev/null) stdout in order to achieve the desired behavior as when under xdm. Note that this should be considered a bug in xinit. xinit should behave like xdm and create a new session for itself and its children via setsid(2), a session that does not have a controlling terminal, and send stdout to /dev/null for its children. Although we can ditch the controlling terminal for ROX-Session and its children, apparently some programs out there (vim?) are smart enough to find out what it would've been (how, I don't know). So we'd need to redirect stdout before the children execute in ROX-Filer (do this in rox_spawn()). AHA BUT here is an update: We can put xinit and its kids into their own session. util-linux ships with a command-line version of setsid(2). We can add this to the startx script to get a new session. (The startx script comments do speak of having site admins write better versions....) stdout will also have to go to /dev/null by using the patch or having the startx script do it (again, startx script might want to send stderr to a file as well). Then we will see the desired behavior as under xdm. -- Keith R. John Warno [k r j w at optonline dot net] "The great thing about America is everybody should vote." -- George "Dubuhyuh" Bush, Austin, Texas, Dec. 8, 2000 |