Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

How to restart only the graphical side of OS X UNIX
I see a lot of hints, such as the one to remove 10.5's translucent menu bar, that tell you to restart your computer for the changes to take effect. However, you only really need to restart the WindowServer, which handles the graphical part of the system. I just do that in Terminal, with this command:
sudo killall -HUP WindowServer
Warning: All your opened programs will quit immediately! This is like a restart, but of only the graphical part of the system. Quit your open programs first! You have been warned. Here's what happens:
  • kill is a program to send signals (terminate or just "signals") to Unix programs -- and in OS X, all programs are Unix programs. killall is the same, but you can use the name of the program instead of its process ID (pid). The dark side is that if you have more than one program with the same name, all programs will receive the kill signal.
  • -HUP is a signal that usually says to the process that configuration files are changed and the process must be restarted.
  • WindowServer is the program that manages the graphical side of OS X.
You can see all the available signals by typing kill -l, but play with care!

[robg adds: A comment on the queue site notes that this may be useful for those times when the GUI locks up, if you're still able to connect via ssh -- try a restart of the window server before forcing a full reboot.]
    •    
  • Currently 3.17 / 5
  You rated: 1 / 5 (6 votes cast)
 
[33,405 views]  

How to restart only the graphical side of OS X | 14 comments | Create New Account
Click here to return to the 'How to restart only the graphical side of OS X' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How to restart only the graphical side of OS X
Authored by: Johnny bison on Dec 05, '07 08:29:45AM

This is silly. If the graphical side of the OS needs to be relaunched then a logout will suffice. The windowserver dies, and relaunches on logout. And your applications get quit cleanly.



[ Reply to This | # ]
Try reading
Authored by: luomat on Dec 05, '07 09:53:22AM

This can be helpful if the GUI is locked up. How do you intend to logout when the keyboard and mouse don't respond?

If you can ssh in from another computer or your jailbroken iPhone you can restart the GUI WITHOUT rebooting.



[ Reply to This | # ]
Try reading
Authored by: barefootguru on Dec 05, '07 10:28:10AM

When my GUI has died but I can still SSH in, I _want_ to reboot the whole system so I know there's no gremlins lurking. For this I use sudo reboot.



[ Reply to This | # ]
Not quite.
Authored by: mdeatherage on Dec 05, '07 09:54:02AM

Logging out does not kill WindowServer. That's why logging out isn't sufficient to make the "non-transparent menu bar" hint work; WindowServer lives on. (This is easy to see in Leopard's Activity Monitor when viewing all processes hierarchically: the system-wide occurrence of launchd owns windowserver, as well as one more instance of launchd for each logged-in user.) That's why we said this in MDJ/MWJ 2007.12.03, because we hadn't seen anyone else point this out.

I think you're thinking of loginwindow, which requires WindowServer to run (obviously, or it wouldn't be showing a window). Logging everyone out may relaunch loginwindow, but not WindowServer. You need to restart or, more daringly, quit WindowServer to get it to relaunch.



[ Reply to This | # ]
Not quite.
Authored by: Johnny bison on Dec 06, '07 06:20:15AM

Maye it is true in leopard, which I do not have yet, that the windowserver lives on as a process on logout. On previous systems the logout relaunches windowserver ( with no other users logged in, of course). In which case mark this as a leopard fix. In the older systems the relaunch of the loginwindow *also* causes the windowserver to relaunch. The paradigm is : logout cleanly ( handled by loginwindow), loginwindow quits, windowserver sees the loginwindow go down, windowserver quits, launchd( or init in previous systems) relaunches loginwindow which tickles the windowserver to relaunch. Fairly clean. Similarly the loginwinodow will exit cleanly ( unlike other applications) when the windowserver dies.

The problem with killing the windowserver is that you may leave dummy processes around, as the windowserver is ( or was pre-leopard for what I know) the parent process of all applications which present GUI. A busy process writing to disk will still be writing to disk, but invisible, after the windowserver is killed. The new windowserver has it's own session which preious sessioned applications cannot connect to, so no windows.

Even *if* the windowserver can catch the interupt and kill it's process this is by no means the safest way of exiting. ( I understand there is a difference between kill -hup and kill -9 which is way more dangerous since it is a kill, not an interrupt) as the other applications will be killed, or interrupted, and may not quit correctly, if at all. Carbon applications will probably behave badly, for instance.

As for the guy who suggested I *read* the comment. The original comment about the translucent menu fix did not mention ssh, and in any case for the reasons I mention killing windowserver makes it a bad idea in all cases.



[ Reply to This | # ]
How to restart only the graphical side of OS X
Authored by: xanadu420 on Dec 05, '07 08:46:23AM
If I'm not mistaken
sudo killall -1 WindowServer
is the same as
sudo killall -HUP WindowServer
and is two keystrokes shorter :-)

[ Reply to This | # ]
How to restart only the graphical side of OS X
Authored by: hackerssidekick on Dec 05, '07 11:05:13AM

Yeah, but I find that HUP (= Hang UP) is much easier to understand and remember than some arbitrary number :). Having said that, if you know (and can remember) all the signal numbers then well done!



[ Reply to This | # ]
How to restart only the graphical side of OS X
Authored by: ubrgeek on Dec 06, '07 08:37:12AM

I've got a (mostly) unrelated comment/question. If the non-transparent menu bar stops being transparent, is there a way to make it semi-transparent again? (Not sure what happened to it, but it's solid again.)



[ Reply to This | # ]
How to restart only the graphical side of OS X
Authored by: LC on Dec 09, '07 05:17:25PM

When I used X11 window managers every day, sometimes the wm would get messed up and I didn't want to lose any windows or processes.

Within olvwm, I could send a -USR1 signal to the wm and it would restart itself (without losing anything).

Within dtwm (CDE's wm), I could send it a f.restart -noconfirm (using a little program called dtwmcmd), and the wm would restart itself (without losing anything).

Does anyone know whether OS X's wm has a restart function, like the ones that I've mentioned above, and whether we can switch consoles (or ssh in) and send it a signal/command that would gently restart it (without losing anything)?? Thanks; Larry.



[ Reply to This | # ]
How to restart only the graphical side of OS X
Authored by: LC on Dec 10, '07 04:58:59PM
I was also wondering about the hidden features of quartz-wm, I guess we only see that running when X11.app is running; Larry

[ Reply to This | # ]
How to restart only the graphical side of OS X
Authored by: aardvarko on Dec 10, '07 09:23:48AM

All GUI client processes die when their WindowServer connection is broken.



[ Reply to This | # ]
How to restart only the graphical side of OS X
Authored by: Gamoe on Dec 24, '07 01:04:02PM

Yes, but how do you even get to the Terminal if the GUI is completely locked up? I know in Linux we can Ctrl-Alt-F1/2/3/etc. to get a Terminal and shut down any processes, but don't see any such option in Mac OS X.



[ Reply to This | # ]
How to restart only the graphical side of OS X
Authored by: snuffop on Mar 22, '08 12:08:17AM

you can always ssh from outside into your hung box.



[ Reply to This | # ]
Excellent tip!
Authored by: gordyt on Dec 02, '09 06:41:36AM

I just now happened to find my laptop in this funky state and was able to ssh in from another machine and reset the window manager as you described. Thanks for posting this!



[ Reply to This | # ]