[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: about startx



jqdkf@zju.edu.cn wrote:

On Tue, May 27, 2003 at 08:58:32AM -0500, Kent West wrote:
westk[@westek]:/home/westk/BIN> cat sx
#!/bin/bash
echo Script is running
startx -- :1 > /dev/null 2>&1 &
echo Script is running

westk[@westek]:/home/westk> sx
Script is running
Script is running

but no starting of X.

However, removing the final ampersand on the startx line, so it becomes this:
startx -- :1 > /dev/null 2>&1

does work.

Yes, it does. But I'm still eager to know what's wrong with it, as I can
start other programs with & in the script.
Anyway, thanks a lot, it does save me some type.

I'm no scripting expert, but I believe what is happening is the following:

1 - A new bash shell is started.
2 - startx is started, and is backgrounded by the ampersand. Since startx is a shell script, it starts a new shell within the bash shell created in step 1. 3- The script ends, causing the new bash shell to be destroyed, and in the process destroying any new shells it spawned, but allowing executables to continue running. Thus some programs (not scripts) will work, but some (scripts) won't.

Without the ampersand, the script can't end, and thus the new shells don't get terminated.

Any shell scripting experts out there want to comment?

--
Kent



Reply to: