On 27 May 2002 20:22:48 +0200, Ulrich Fahrenberg wrote:
>
> On Mon, 27 May 2002, Jukka Lehti wrote:
>
> > AddToMenu "Utilities"
> > + "Program Menu" Title
> > + "xterm" Exec exec xterm &
> > + "Mozilla" Exec exec mozilla &
> > + "" Nop
> > + "Applications" Popup Apps
> > + "Utilities" Popup Utils
>
> (Answering a question you didn't ask:) The & in your menu probably
> don't cause any trouble, but they are unnecessary, as ``Exec exec''
> already means that the shell is running the command in background and
> exits immediately.
The "&" is indead redudant here, but your explanation is not correct.
The only way to run something in the shell background is to specify "&".
Since this question is raised a lot, here is what actually happens.
Arrow actually means 2 operations: fork and exec in the forked process.
-----------------------------------------------------------------------
1) Exec xterm
fvwm -> shell -> xterm
pid=1 pid=2 pid=3
Process table after 1 second: pid=1, pid=2, pid=3.
fvwm does not wait for shell, shell waits for xterm.
(Some shells like bash do optimizations here, automatically add "exec".)
-----------------------------------------------------------------------
2) Exec exec xterm
fvwm -> shell exec xterm
pid=1 pid=2 pid=2
Process table after 1 second: pid=1, pid=2.
fvwm does not wait for shell, shell is replaced by xterm.
-----------------------------------------------------------------------
3) Exec xterm &
fvwm -> shell -> shell -> xterm
pid=1 pid=2 pid=3 pid=4
Process table after 1 second: pid=1, pid=3, pid=4.
fvwm does not wait for shell, shell pid=2 forks because of "&" and
immediately exits. shell pid=3 waits for xterm.
(Many shells do optimizations here and behave just like in the case 4.)
-----------------------------------------------------------------------
4) Exec exec xterm &
fvwm -> shell -> shell exec xterm
pid=1 pid=2 pid=3 pid=3
Process table after 1 second: pid=1, pid=3.
fvwm does not wait for shell, shell pid=2 forks because of "&" and
immediately exits. shell pid=3 is replaced by xterm.
You see, the most optimal is "Exec exec xterm".
Regards,
Mikhael.
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Mon May 27 2002 - 15:24:58 BST