Skip to content

Problems with the OS X 10.5.5 update and X11

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 noticed that ssh was hanging immediately after some X11 related operations were performed. I have ssh configured to set up X11 forwarding unless otherwise specified on the ssh command line. By explicitly disabling X11 forwarding (using ssh -x) 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.

With X11 being the suspected cause of the ssh problem I tried launching X11.app manually by double clicking the X11 application in /Applications/Utilities/X11.app. I noticed that X11 did not bounce in the Dock. In fact X11 did not appear in the Dock at all. That’s odd…

I noticed the following lines repeating in the system logs:
Oct 17 10:25:34 macBook com.apple.launchd[113] (org.x.startx): Throttling respawn: Will start in 10 seconds
Oct 17 10:26:04 macBook com.apple.launchd[113] (org.x.startx): Throttling respawn: Will start in 10 seconds

At least these log entries confirm that X11 is unhappy.

The machine on which I first noticed this problem may have had the XQuartz 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:

Before upgrade After upgrade Exhibits problem?
OS X 10.5.4 (PPC)
XQuartz not installed
OS X 10.5.5 (PPC)
XQuartz not installed
yes
OS X 10.5.4 (Intel)
Apple X11 installed
XQuartz not installed
OS X 10.5.5 (Intel)
XQuartz not installed
yes
OS X 10.5.4 (Intel)
XQuartz not installed
OS X 10.5.5 (Intel)
XQuartz installed (updated to 2.3.1)
yes
OS X 10.5.4 (Intel)
XQuartz installed
OS X 10.5.5 (Intel)
XQuartz installed (updated to 2.3.1)
yes

Since the problem can be reproduced on machines that have never had XQuartz installed I can rule out XQuartz as contributing to the problem.

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 exec command to replace the current shell process with another process.

I have used my old .profile start-up script for bash has been in use on various machines since OS X 10.2 without problems. This old script was:

if [ -e /sw/bin/tcsh ]; then
    # We prefer to use the fink installed version of tcsh..
    exec /sw/bin/tcsh
elif [ -e /bin/tcsh ]; then
    # ... but we will use the OS X installed version if it exists
    echo "warning: using Apple version of tcsh from /bin/tcsh"
    exec /bin/tcsh
else
    echo "error: could not find a version of tcsh to exec!"
    echo "       dropping to default bash setup (no fink environment)"
fi

Nothing exciting there other than the exec. exec is commonly used in this manner to dynamically change the user’s shell for typically one of two reasons:

  • 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
  • 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.)

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. bash provides the options –noprofile and –norc to provide this level of control over the script execution environment.

Working on the theory that the exec commands are tickling this X11 start-up problem I have worked around the problem by switching to the following .profile start-up script:

if [ -t 0 ]; then
  export INTERACTIVE=true
else
  export INTERACTIVE=false
fi

if [ "${INTERACTIVE}" == "true" ]; then
  if [ -e /sw/bin/tcsh ]; then
    # We prefer to use the fink installed version of tcsh..
    exec /sw/bin/tcsh
  elif [ -e /bin/tcsh ]; then
    # ... but we will use the OS X installed version if it exists
    echo "warning: using Apple version of tcsh from /bin/tcsh"
    exec /bin/tcsh
  else
    echo "error: could not find a version of tcsh to exec!"
    echo "       dropping to default bash setup (no fink environment)"
  fi
fi

This work-around avoids tickling the problem with the Apple start-up scripts for X11 by determining if the shell invoking my .profile 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 .profile file executes the commands in my old start-up script.

Note the use of test -t 0 to determine if we are an interactive shell. Until recently I used tty -s to determine if the script was in an interactive shell. Apparently POSIX has deprecated the -s option so test -t 0 may be a safer choice.

Tagged

How to install Windows XP on an external USB drive connect to an Apple MacBook

In August 2006, I posted instructions on how to install Windows XP onto an external USB drive to the macrumors.com forums. I’m reposting the instructions here so that this information does not get lost.

Some notes on these instructions:

  • These instructions result in an installation of Windows XP that is completely contained on an external USB drive. Other approaches usually create a Windows partition on the internal drive.
  • The instructions require you to remove your internal drive from your MacBook during the installation. If you do not remove the internal drive you risk damaging the operating systems installed on your internal drive. Also, if the internal drive is not removed then Windows will not correctly install onto the external drive.
  • For the past year I have relied on VMware to eliminate the need to boot to Windows on bare hardware.

Windows XP on USB for MacBook instructions:

I have completed this install 4 different times.

Steps:

  1. Modify Windows install CD to support booting off a USB drive. (Instructions are on the web at http://www.ngine.de/index.jsp?pageid=4176.)
  2. Remove internal hard drive from MacBook.
  3. Connect external USB drive to MacBook.
  4. Boot from modified Windows install CD.
  5. Progress through Windows install, creating partitions and formating the partitions as you see fit. In most of my installed I partitioned the drive under OS X using a firewire connection to the drive since Disk Tool isn’t always happy partitioning USB drives. I have also successfully used a GParted boot disk to partition an external USB drive and then running the Windows installer without modifying the partition table on the external drive.
  6. Wait for about 34 minutes for the Windows install to finish.
  7. Reboot into Windows on the external drive.
  8. Install the Apple device drivers for windows.
  9. Replace internal drive.

After all of this you will be able to boot into OS X. You will not be able to boot into Windows by holding down the option key when booting. Instead you will need to connect the USB drive to a running OS X system, open the Startup Disk Preference Pane and select the windows partition. Then when you reboot you will boot into Windows. To return to OS X you need to use the Windows Startup Disk control panel to select OS X.

(OS X will also boot if the USB drive is not connected.)

This fiddling with the Startup Disk Preference Pane is a limitation that I haven’t found a way to work around. For me, I can live with this since I only boot to Windows occasionally.

Additional notes:

  • I have always plugged my USB drive into the rear-most USB port on my MacBook (the USB port closest to the MagSafe power connector). Some forum posts report that using another USB port results in Windows errors.
  • Windows is unable to use a pagefile that on an external USB drive. After completing a install based on these instructions you will not be able to set up a working pagefile for Windows. Since I rarely boot to Windows and only then put it to light use then my 2GB of main memory means that I don’t require a working pagefile. Realistically, if you have less than 1.5GB of RAM in your Mac then you are will have problems with Windows running out of memory. Your mileage may vary.
  • Even after following these instructions exactly some people have reported that they are unable to successfully boot Windows. It is likely that these failed attempts are due to differences in USB enclosure implementations and/or Windows memory issues.
Tagged , , ,

Embedding a command line tool within a Cocoa application

Back in 2006 I posted a forum question seeking help with embedding a command line tool inside a Cocoa application. After a few days I had muddled out a way to both embed the command line tool and set up XCode to automatically build the command line tool when the Cocoa wrapper is rebuilt. I posted my solution answering my own question.

Recently I received a message from someone who stumbled on my solution and found it useful. I’m reposting the solution here so that this information does not get lost.

My original question:

I’m hacking together a small Cocoa application in XCode. I have all the GUI and events coded up and now I need to integrate a command line tool that I coded up in C a while back.

Poking around in the package contents for a few applications I’ve noticed that it is not uncommon for developers to package up small command line tools within the main Cocoa application. Presumably these command line tools are executed as a new process from the Cocoa application.

I’m developing in XCode and have manged to import the source code for the command line tool as say command_line.c. What do I need to do to have this file built as a command line tool that is embedded in the main Cocoa application?

My solution:
(Warning: Long and technical post.)
Continue reading ›

Tagged , ,

I’d like to buy a vowel… will the iPhone bring English to SMS?

iphonesms.png

14 days into the iPhone and I’m very happy with the iPhone. There are omitted features that would be nice to have, such as a List application. But everything the phone currently does it does well. I haven’t got lost in the iPhone interface at any time unlike every other mobile phone I’ve used. The experience has been so good that I am happy to discount the mail issues and SyncServices corruption on my Mac last week as an oddity with my setup. The SyncServices corruption ended up taking a day to resolve by moving all my files into a fresh OS X account.

Last night I used the iPhone SMS application for the first time. I typed out my message. It wasn’t until 3 lines into the message before I realized that I was typing complete sentences. I felt no need 4 sms spk.

Vowels are here, punctuation too. Hello prepositions, how I missed you.

Back in Australia, sending an SMS was a few cents a message with SMS service included in the phone service. So SMS charges ended up being background noise in my mobile phone costs. It wouldn’t surprise me if 50% of my Australian mobile phone use was short messages.”xing hbr bdg - b @ qvb in 15″ was a common message to sync up with friends in the city. Hmmm, that’s almost as ugly as writing Perl.

In the USA I’ve found SMS to be not worth using. This avoidance has been as much about the per message cost as it was about messages not getting through to the receiver and the way that each of my US cell phones have made writing a short messages difficult.

Part of the issue with SMS on my US phones was that a ridiculous amount of screen real-estate occupied by non-message elements: To, From, and Subject fields that were not relevant to SMS, soft-button labels that were not needed for the SMS task, an so on. The iPhone fixes this issue by virtue of its large, high-res screen. Additionally, the iPhone SMS application is focused solely on the SMS task showing the SMS history, the current SMS, the keyboard and a send button. The SMS history is shown as an instant-message like history above the current SMS text area. The result is a very simple UI for what is essentially a very simple task.

This simplification is a result of Apple’s design aesthetic, but I also wonder if it is also a side-effect of building phone software in individual pieces rather than as a monolithic block of code that handles all phone functions. Each function on the iPhone (SMS, Phone, Address Book, Mail, Settings, Safari, etc) is implemented as a separate stand-alone application. This focus on an application doing one task well rather than trying to solve everything in one application leads to simpler and more task-focused applications.

It might be the IM-like history view. It may be that the message that I am composing fits onto the screen. It may just be my time away from SMS over the past 4 years. In all likelihood it is probably the combination of these aspects that result in making it feel natural to write short messages using actual English on the iPhone.

Though it’s probably too much to hope that the iPhone will bring back natural language and relegate SMS-speak to the dustbin of history. At least the iPhone helps to show SMS-speak for what it is—a kludge to deal with bad SMS user interfaces of the past.

Tagged ,

iPhone Firmware… come out, come out, wherever you are.

After poking at these crash report files I spent a little time searching my MacBook to find the iPhone firmware. It turns out that the firmware is not part of the basic iTunes 7.3 install.

Somehow I got the iPhone Mail client into a weird state where it was downloading email but would only show me the initial set-up your Mail client display. To resolve this issue I decided that it was time to use iTunes to restore my iPhone to factory settings. This triggered iTunes to start a 91.2MB download that is named iPhone Software Update.

The iPhone Software Update is downloaded into ~/Library/iTunes/iPhone Software Updates folder for the current user. This update is also available as a direct download from Apple servers at http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone/061-3538.20070629.B7vXa/iPhone1,1_1.0_1A543a_Restore.ipsw.

The iPhone1,1_1.0_1A543a_Restore.ipsw file is a ZIP archive containing the following files:

694-5259-38.dmg
694-5262-39.dmg
Firmware
Firmware/all_flash
Firmware/all_flash/all_flash.m68ap.production
Firmware/all_flash/all_flash.m68ap.production/applelogo.img2
Firmware/all_flash/all_flash.m68ap.production/batterycharging.img2
Firmware/all_flash/all_flash.m68ap.production/batterylow0.img2
Firmware/all_flash/all_flash.m68ap.production/batterylow1.img2
Firmware/all_flash/all_flash.m68ap.production/DeviceTree.m68ap.img2
Firmware/all_flash/all_flash.m68ap.production/iBoot.m68ap.RELEASE.img2
Firmware/all_flash/all_flash.m68ap.production/LLB.m68ap.RELEASE.img2
Firmware/all_flash/all_flash.m68ap.production/manifest
Firmware/all_flash/all_flash.m68ap.production/needservice.img2
Firmware/all_flash/all_flash.m68ap.production/recoverymode.img2
Firmware/dfu
Firmware/dfu/iBSS.m68ap.RELEASE.dfu
Firmware/dfu/WTF.s5l8900xall.RELEASE.dfu
kernelcache.restore.release.s5l8900xrb
Restore.plist

The iPhone restore process takes a couple of minutes for iTunes to transfer the firmware to the phone. After the transfer, the phone reboots, and then takes a few seconds for AT&T to activate the phone.

Once the phone is activated iTunes allows the user to Set up as a new iPhone, or to Restore the phone from an earlier backup. Restoring from backup involves the iPhone rebooting again followed immediately by an automatic sync of Contacts, Music. (Presumably this also will cause a sync of videos and photos if you have those items setup to sync.)

After the restore the iPhone needed both my voicemail password and the WiFi password for my home network to be re-entered. The phone had also lost the two pictures I had taken with the iPhone camera… fortunately I had sync’d them into iPhoto. One of these pictures was set as the iPhone Wallpaper and still showed as the wallpaper.

Unfortunately, after the restore the iPhone Mail account is back to downloading over a thousand email messages that I have received and deleted over the past couple of weeks. All of these messages have been deleted using Apple Mail on my MacBook and I have flushed the deleted messages from the mail server. Hopefully this will settle down otherwise I will need to use a separate iPhone email address and run filtering services to limit what gets delivered to the phone.

36 hours after getting it, the iPhone is still looking like a good decision.

Update
The Restore.plist file indicates that the 15MB 694-5259-38.dmg disk image is a RAMDisk image. Presumably this loads into the reported 1Gbit of flash that is presumed to be built into the ARM processor used by the iPhone (ifixit disassembly). The 694-5262-39.dmg file is the “System Restore Image”. This second image file weighs in at 82.3MB and certainly contains the OS X file system, libraries and application files.

Tagged

iPhone Crash Reporting

A few hours after setting up and exploring my iPhone I sync’d it again. During this sync an Apple crash reporter dialog appeared asking permission to send a crash report to Apple. This was a little strange since iTunes was still running and no other processes were active. On looking deeper it turned out that the crash reports were from MobileSafari on the iPhone crashing and the report had been sync’d back to the MacBook to be relayed to Apple.

The report Details button showed a Finder window with two .plist files and two .crash files from MobileSafari. These files look like standard Apple crash reports.

The .plist file is an XML file conforming to Apple’s PropertyList-1.0.dtd and containing the stack trace of the crash in a string element. The .crash file contains the stack trace for all threads in MobileSafari. The .crash stack traces support the viewpoint that the other iPhone applications such as the AddressBook are based on WebKit.

One of these file pairs are shown below.

Continue reading ›

Tagged