Re: X11 0.2 Startup Behaviour
Re: X11 0.2 Startup Behaviour
- Subject: Re: X11 0.2 Startup Behaviour
- From: Randy Ford <email@hidden>
- Date: Thu, 13 Feb 2003 00:00:34 -0600
On Wednesday, February 12, 2003, at 02:16 PM, Dennis Flanigan wrote:
On Tuesday, February 11, 2003, at 11:09 PM, Randy Ford wrote:
xterm&
exec quartz-wm
In my .xinitrc I used:
quartz-vm
instead of:
exec quartz-vm
What is the difference ?
It probably only makes sense if you understand how Unix programs start
other programs. One of the great things about Unix is that a new
process inherits the environment, including security credentials, of
the process that is launching it. The new process can change it's
environment when it needs to, but that's not needed very often.
A process starts a new one by duplicating itself (forking) into two
identical processes. Then, if need be, the child changes its
environment; (it's not normally needed.) After that, the child
replaces itself with another executable. That's the 'exec.'
When the shell launches a process, say quartz-wm, it normally forks,
then the child execs quartz-wm. Then, if the '&' wasn't given to tell
the shell to run the program in the background, the parent waits on the
child to terminate. However, if the shell isn't going to be needed
again, it might as well just not bother with forking, but just go
ahead and do the exec. We tell the shell to do this by using the
'exec' word before the command. Then a new process isn't created, and
the new program just replaces the shell. It could have been named
"don't_fork" instead of "exec", but that would have been harder to type.
There is another use of the 'exec' keyword in the shells, but I don't
want to cloud the mud^?^?^?water. It has to do with changing the
environment of the current or new process. (See the man page for your
shell.)
If you want to see it from the C programmers side you can look at these
man pages:
man 2 fork
man 2 execve
randy.
_______________________________________________
x11-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/x11-users
X11 for Mac OS X FAQ: http://developer.apple.com/qa/qa2001/qa1232.html
Report issues, request features, feedback: http://developer.apple.com/bugreporter
Do not post admin requests to the list. They will be ignored.