{"id":102,"date":"2008-10-17T17:47:02","date_gmt":"2008-10-18T00:47:02","guid":{"rendered":"http:\/\/www.smallersystems.com\/people\/mar\/blog\/?p=84"},"modified":"2008-10-17T17:47:02","modified_gmt":"2008-10-18T00:47:02","slug":"problems-with-the-os-x-1055-update-and-x11","status":"publish","type":"post","link":"https:\/\/michaelrichmond.net\/blog\/2008\/10\/17\/problems-with-the-os-x-1055-update-and-x11\/","title":{"rendered":"Problems with the OS X 10.5.5 update and X11"},"content":{"rendered":"<p>After upgrading to OS X 10.5.5 I ran into an issue with X11 refusing to start. I first noticed this issue as a problem with <span style=\"font-family: courier, monospace;\">ssh<\/span> hanging while trying to establish a connection. When I dug into this problem I noticed that <span style=\"font-family: courier, monospace;\">ssh<\/span> was hanging immediately after some X11 related operations were performed. I have <span style=\"font-family: courier, monospace;\">ssh<\/span> configured to set up X11 forwarding unless otherwise specified on the ssh command line. By explicitly disabling X11 forwarding (using <span style=\"font-family: courier, monospace;\">ssh -x<\/span>) the connection would connect normally. Unfortunately this means that the very cool auto-start of X11 that Apple implemented with OS X 10.5 is lost.<\/p>\n<p>With X11 being the suspected cause of the <span style=\"font-family: courier, monospace;\">ssh<\/span> problem I tried launching <span style=\"font-family: courier, monospace;\">X11.app<\/span> manually by double clicking the X11 application in <span style=\"font-family: courier, monospace;\">\/Applications\/Utilities\/X11.app<\/span>. I noticed that X11 did not bounce in the Dock. In fact X11 did not appear in the Dock at all. That&#8217;s odd&#8230;<\/p>\n<p>I noticed the following lines repeating in the system logs:<br \/>\n<code style=\"font-size: 90%\">Oct 17 10:25:34 macBook com.apple.launchd[113] (org.x.startx): Throttling respawn: Will start in 10 seconds<br \/>\nOct 17 10:26:04 macBook com.apple.launchd[113] (org.x.startx): Throttling respawn: Will start in 10 seconds<\/code><\/p>\n<p>At least these log entries confirm that X11 is unhappy.<\/p>\n<p>The machine on which I first noticed this problem may have had the <a href=\"http:\/\/xquartz.macosforge.org\/trac\/wiki\">XQuartz<\/a> updates to X11 installed at some point. To eliminate this third-party code as a contributor to the problem I attempted to reproduce the problem a few configurations:<\/p>\n<p><center><\/p>\n<table width=\"80%\" style=\"border-collapse: collapse;\">\n<tr style=\"background: rgb(221, 221, 221);\">\n<th style=\"text-align: left; padding: 2px 8px 2px 8px;\">Before upgrade<\/th>\n<th style=\"text-align: left; padding: 0 8px 0 8px;\">After upgrade<\/th>\n<th style=\"padding: 0 8px 2px 8px;\">Exhibits problem?<\/th>\n<\/tr>\n<tr>\n<td style=\"padding: 0 0 1em 8px;\">OS X 10.5.4 (PPC)<br \/>XQuartz not installed<\/td>\n<td style=\"padding: 0 0 1em 8px;\">OS X 10.5.5 (PPC)<br \/>XQuartz not installed<\/td>\n<td style=\"text-align: center; vertical-align: middle;\">yes<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 0 0 1em 8px;\">OS X 10.5.4 (Intel)<br \/>Apple X11 installed<br \/>XQuartz not installed<\/td>\n<td style=\"padding: 0 0 1em 8px;\">OS X 10.5.5 (Intel)<br \/>XQuartz not installed<\/td>\n<td style=\"text-align: center; vertical-align: middle;\">yes<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 0 0 1em 8px;\">OS X 10.5.4 (Intel)<br \/>XQuartz not installed<\/td>\n<td style=\"padding: 0 0 1em 8px;\">OS X 10.5.5 (Intel)<br \/>XQuartz installed (updated to 2.3.1)<\/td>\n<td style=\"text-align: center; vertical-align: middle;\">yes<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 0 0 1em 8px;\">OS X 10.5.4 (Intel)<br \/>XQuartz installed<\/td>\n<td style=\"padding: 0 0 1em 8px;\">OS X 10.5.5 (Intel)<br \/>XQuartz installed (updated to 2.3.1)<\/td>\n<td style=\"text-align: center; vertical-align: middle;\">yes<\/td>\n<\/tr>\n<\/table>\n<p><\/center><\/p>\n<p>Since the problem can be reproduced on machines that have never had XQuartz installed I can rule out XQuartz as contributing to the problem.<\/p>\n<p>Based on a tip found on the Apple support forums I investigated whether any of my shell start-up scripts had any impact on the problem. It appears that Apple has made a change to the way that X11 starts in 10.5.5. These changes make X11 start-up brittle in the face of the common shell start-up idiom of using the <span style=\"font-family: courier, monospace;\">exec<\/span> command to replace the current shell process with another process.<\/p>\n<p>I have used my old <span style=\"font-family: courier, monospace;\">.profile<\/span> start-up script for bash has been in use on various machines since OS X 10.2 without problems. This old script was:<\/p>\n<blockquote>\n<pre>if [ -e \/sw\/bin\/tcsh ]; then\n    # We prefer to use the fink installed version of tcsh..\n    exec \/sw\/bin\/tcsh\nelif [ -e \/bin\/tcsh ]; then\n    # ... but we will use the OS X installed version if it exists\n    echo \"warning: using Apple version of tcsh from \/bin\/tcsh\"\n    exec \/bin\/tcsh\nelse\n    echo \"error: could not find a version of tcsh to exec!\"\n    echo \"       dropping to default bash setup (no fink environment)\"\nfi<\/pre>\n<\/blockquote>\n<p>Nothing exciting there other than the <span style=\"font-family: courier, monospace;\">exec<\/span>. <span style=\"font-family: courier, monospace;\">exec<\/span> is commonly used in this manner to dynamically change the user&#8217;s shell for typically one of two reasons:<\/p>\n<ul>\n<li>to change to a user shell that uses a different syntax (such as csh or ksh) without risking breaking system shell scripts and installer scripts, or<\/li>\n<li>to lock the user into a program that limits what the user can do on the system. (For example, locking the user into a menu-driven terminal program rather than providing full shell access.)<\/li>\n<\/ul>\n<p>Back when I worked on Solaris and Ultrix (showing my age) machines, the guidance was that shells used to start system services should be executed with options that prevent execution of user-supplied shell configuration files. This was advised to ensure that commands and environment variables applied by the user-supplied configuration files would not interfere with the system service. Said in another way, you want to ensure that your services scripts are executing in a known environment rather than an environment that the user has futzed with. <span style=\"font-family: courier, monospace;\">bash<\/span> provides the options <span style=\"font-family: courier, monospace;\">&#8211;noprofile<\/span> and <span style=\"font-family: courier, monospace;\">&#8211;norc<\/span> to provide this level of control over the script execution environment.<\/p>\n<p>Working on the theory that the <span style=\"font-family: courier, monospace;\">exec<\/span> commands are tickling this X11 start-up problem I have worked around the problem by switching to the following <span style=\"font-family: courier, monospace;\">.profile<\/span> start-up script:<\/p>\n<blockquote>\n<pre>if [ -t 0 ]; then\n  export INTERACTIVE=true\nelse\n  export INTERACTIVE=false\nfi\n  \nif [ \"${INTERACTIVE}\" == \"true\" ]; then\n  if [ -e \/sw\/bin\/tcsh ]; then\n    # We prefer to use the fink installed version of tcsh..\n    exec \/sw\/bin\/tcsh\n  elif [ -e \/bin\/tcsh ]; then\n    # ... but we will use the OS X installed version if it exists\n    echo \"warning: using Apple version of tcsh from \/bin\/tcsh\"\n    exec \/bin\/tcsh\n  else\n    echo \"error: could not find a version of tcsh to exec!\"\n    echo \"       dropping to default bash setup (no fink environment)\"\n  fi\nfi<\/blockquote><\/pre>\n<p>This work-around avoids tickling the problem with the Apple start-up scripts for X11 by determining if the shell invoking my <span style=\"font-family: courier, monospace;\">.profile<\/span> is an interactive shell (i.e. something that a user will type commands into). If the shell is not interactive then set an environment variable and exit. Otherwise, the <span style=\"font-family: courier, monospace;\">.profile<\/span> file executes the commands in my old start-up script.<\/p>\n<p>Note the use of <span style=\"font-family: courier, monospace\">test -t 0<\/span> to determine if we are an interactive shell. Until recently I used <span style=\"font-family: courier, monospace\">tty -s<\/span> to determine if the script was in an interactive shell. Apparently POSIX has deprecated the <span style=\"font-family: courier, monospace\">-s<\/span> option so <span style=\"font-family: courier, monospace\">test -t 0<\/span> may be a safer choice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After upgrading to OS X 10.5.5 I ran into an issue with X11 refusing to start. I first noticed this issue as a problem with ssh hanging while trying to establish a connection. When I dug into this problem I &hellip; <a href=\"https:\/\/michaelrichmond.net\/blog\/2008\/10\/17\/problems-with-the-os-x-1055-update-and-x11\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,31],"tags":[],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-apple","category-osx"],"_links":{"self":[{"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/comments?post=102"}],"version-history":[{"count":0,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"wp:attachment":[{"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelrichmond.net\/blog\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}