views:

174

answers:

3

I use startx to start X which will evaluate my .xinitrc. In my .xinitrc I start my window manager using /usr/bin/mywm. Now, if I kill my WM (in order to f.e. test some other WM), X will terminate too because the .xinitrc script reached EOF. So I added this at the end of my .xinitrc:

while true; do sleep 10000; done

This way X won't terminate if I kill my WM. Now my question: how can I do an infinite sleep instead of looping sleep? Is there a command which will kinda like freeze the script?

Best regards

A: 

A possible solution around a wait command waiting for a non terminating process:

yes > /dev/null & pid=$!
wait $pid
mouviciel
Using `yes` would require some cpu time. I guess that ain't very nice.
watain
`yes` is only an example.
mouviciel
+3  A: 

Maybe this seems ugly, but why not just run cat and let it wait for input forever?

Michał Trybus
That's probably the best way to do it. My answer was basically `read nothing`, but read _will_ return if input is ready on the controlling tty, where `cat` would just keep swallowing input. +1
Tim Post
I actually thought our solutions didn't differ much, but I don't know the guts of read. Thanks
Michał Trybus
Now that's nice, I would've never thought of using `cat`. I guess it won't swallow any CPU time either. Thanks a lot!
watain
@Michal - well try it. At a bash prompt type `read nothing`, then hit enter. Read got its input and exited. `cat` however just keeps waiting for more input (or EOF).
Tim Post
@Tim, now I understand what `read` actually does: "read - read a line from standard input" - from `man read`.
Michał Trybus
A: 

Instead of killing the window manager, try running the new one with --replace or -replace if available.

Dennis Williamson
If I use `--replace` I always get a warning like `another window manager is already running`. That doesn't make much sense to me tho.
watain