[Desire Android Development] foobar66:
OK, just for the sake of completeness:

Here is my shutdown script:

#!/system/bin/sh

/system/bin/logwrapper echo "Running my own shutdown script"

sync

sync

sync

/system/bin/logwrapper echo "Listing running processes"

/system/bin/logwrapper busybox ps

/system/bin/logwrapper echo "Trying unmount of /dev/block/mmcblk0p2"

/system/bin/logwrapper /system/bin/umount /dev/block/mmcblk0p2

/system/bin/logwrapper echo "Now phone is really shutting down"

/system/bin/shutdown.orig

And the output when I shut down the phone (normal shutdown):

I/echo ( 854): Listing running processes

I/busybox ( 856): PID USER VSZ STAT COMMAND

I/busybox ( 856): 1 0 344 S /init

I/busybox ( 856): 2 0 0 SW [kthreadd]

I/busybox ( 856): 3 0 0 SW [ksoftirqd/0]

I/busybox ( 856): 4 0 0 SW [events/0]

I/busybox ( 856): 5 0 0 SW [khelper]

I/busybox ( 856): 6 0 0 SW [async/mgr]

I/busybox ( 856): 7 0 0 SW [suspend]

I/busybox ( 856): 8 0 0 SW [avs/0]

I/busybox ( 856): 9 0 0 SW [sync_supers]

I/busybox ( 856): 10 0 0 SW [bdi-default]

I/busybox ( 856): 11 0 0 SW [kblockd/0]

I/busybox ( 856): 12 0 0 SW [kmmcd]

I/busybox ( 856): 13 0 0 SW [bluetooth]

I/busybox ( 856): 14 0 0 SW [kondemand/0]

I/busybox ( 856): 15 0 0 SW [smd_tty]

I/busybox ( 856): 16 0 0 SW [qmi]

I/busybox ( 856): 17 0 0 DW [rpcrouter]

I/busybox ( 856): 18 0 0 SW [krpcserversd]

I/busybox ( 856): 19 0 0 SW [microp_work_q]

I/busybox ( 856): 20 0 0 SW [detection/0]

I/busybox ( 856): 21 0 0 SW [button/0]

I/busybox ( 856): 22 0 0 SW [detect/0]

I/busybox ( 856): 23 0 0 SW [button/0]

I/busybox ( 856): 24 0 0 SW [kswapd0]

I/busybox ( 856): 25 0 0 SW [aio/0]

I/busybox ( 856): 26 0 0 SW [crypto/0]

I/busybox ( 856): 37 0 0 SW [panel_on/0]

I/busybox ( 856): 38 0 0 SW [msm_serial_hs]

I/busybox ( 856): 39 0 0 SW [mtdblockd]

I/busybox ( 856): 40 0 0 SW [msm_hsusb]

I/busybox ( 856): 41 0 0 SW [usb_mass_storag]

I/busybox ( 856): 42 0 0 SW [gs_tty]

I/busybox ( 856): 43 0 0 SW [synaptics_wq]

I/busybox ( 856): 44 0 0 SW [proximity_wq]

I/busybox ( 856): 45 0 0 SW [ls_wq/0]

I/busybox ( 856): 46 0 0 SW [curcial_wq]

I/busybox ( 856): 47 0 0 SW [w1_bus_master1]

I/busybox ( 856): 48 0 0 SW [kstriped]

I/busybox ( 856): 49 0 0 SW [binder]

I/busybox ( 856): 50 0 0 SW< [krfcommd]

I/busybox ( 856): 51 0 0 SW [ds2784-battery.]

I/busybox ( 856): 52 0 0 SW [flush-31:0]

I/busybox ( 856): 53 0 0 SW [mmcqd]

I/busybox ( 856): 55 0 3416 R /sbin/adbd

I/busybox ( 856): 63 0 0 SW [flush-179:0]

I/busybox ( 856): 73 0 0 SW [jbd2/mmcblk0p2-]

I/busybox ( 856): 74 0 0 SW [ext4-dio-unwrit]

I/busybox ( 856): 82 1000 812 S /system/bin/servicemanager

I/busybox ( 856): 83 0 3856 S /system/bin/vold

I/busybox ( 856): 84 0 3864 S /system/bin/netd

I/busybox ( 856): 85 0 672 S /system/bin/debuggerd

I/busybox ( 856): 86 1001 14336 S /system/bin/rild

I/busybox ( 856): 87 0 119m S zygote /bin/app_process -Xzygote /system/bin --zygot

I/busybox ( 856): 88 1013 34040 S /system/bin/mediaserver

I/busybox ( 856): 89 1002 1268 S /system/bin/dbus-daemon --system --nofork

I/busybox ( 856): 90 0 812 S /system/bin/installd

I/busybox ( 856): 91 1017 1732 S /system/bin/keystore /data/misc/keystore

I/busybox ( 856): 92 0 792 S /system/bin/ipd

I/busybox ( 856): 93 1008 716 S /system/bin/akmd

I/busybox ( 856): 113 1000 288m S system_server

I/busybox ( 856): 207 0 0 SW [iscan_sysioc]

I/busybox ( 856): 208 0 0 SW [dhcp_sysioc]

I/busybox ( 856): 209 0 0 SW [dhd_watchdog]

I/busybox ( 856): 210 0 0 SW [dhd_dpc]

I/busybox ( 856): 211 0 0 SW [dhd_sysioc]

I/busybox ( 856): 213 10013 174m S com.htc.android.htcime

I/busybox ( 856): 222 1001 182m S com.android.phone

I/busybox ( 856): 229 10031 175m S android.process.acore

I/busybox ( 856): 234 9999 257m S com.htc.launcher

I/busybox ( 856): 257 10022 196m S com.google.process.gapps

I/busybox ( 856): 270 10031 160m S com.android.htccontacts

I/busybox ( 856): 284 1007 664 S /system/bin/logwrapper /system/bin/wpa_supplicant -D

I/busybox ( 856): 286 1010 2048 S /system/bin/wpa_supplicant -Dwext -ieth0 -c/data/mis

I/busybox ( 856): 293 10001 159m S com.htc.bgp

I/busybox ( 856): 306 1000 163m S com.android.settings

I/busybox ( 856): 328 1014 856 S /system/bin/dhcpcd -ABKL eth0 -h android_93c1e17bc42

I/busybox ( 856): 354 10014 152m S com.android.updater

I/busybox ( 856): 364 10001 151m S com.htc.bg

I/busybox ( 856): 374 10002 156m S android.process.media

I/busybox ( 856): 385 1000 150m S com.htc.RosieUtility

I/busybox ( 856): 404 10005 151m S com.htc.android.worldclock

I/busybox ( 856): 413 10018 159m S com.google.android.gm

I/busybox ( 856): 424 10039 161m S com.google.android.partnersetup

I/busybox ( 856): 473 10045 153m S com.htc.fm

I/busybox ( 856): 482 10027 150m S com.htc.htcMessageUploader

I/busybox ( 856): 490 10020 152m S com.htc.music

I/busybox ( 856): 499 10024 162m S com.android.mms

I/busybox ( 856): 510 10033 151m S com.htc.newsreader

I/busybox ( 856): 523 10021 150m S com.htc.opensense.pluginmanager

I/busybox ( 856): 538 10088 153m S com.reader.androidworld3

I/busybox ( 856): 546 10088 152m S com.reader.androidworld3:remote

I/busybox ( 856): 552 10090 166m S com.jupiterapps.phoneusage

I/busybox ( 856): 562 10074 160m S com.koushikdutta.rommanager

I/busybox ( 856): 573 10057 154m S com.mhuang.overclocking

I/busybox ( 856): 582 10077 152m S com.woutergo.tvgidsbe

I/busybox ( 856): 593 10087 155m S com.keramidas.TitaniumBackup

I/busybox ( 856): 599 10010 151m S com.noshufou.android.su

I/busybox ( 856): 618 10030 157m S com.android.vending

I/busybox ( 856): 629 10015 169m S com.google.android.apps.maps:FriendService

I/busybox ( 856): 638 10082 150m S com.koushikdutta.rommanager.license

I/busybox ( 856): 645 10086 152m S com.cousinHub.meteo

I/busybox ( 856): 661 10051 153m S com.google.android.apps.uploader

I/busybox ( 856): 674 10068 154m S com.dropbox.android

I/busybox ( 856): 683 10085 156m S com.google.android.apps.reader

I/busybox ( 856): 694 10069 151m S com.dynotes.miniinfo

I/busybox ( 856): 701 10059 156m S com.anddoes.fancywidget.pro

I/busybox ( 856): 711 10071 151m S com.grrzzz.remotesmsfull

I/busybox ( 856): 718 9997 163m S com.htc.android.mail

I/busybox ( 856): 727 9999 189m S com.htc.widget.clockwidget

I/busybox ( 856): 737 10056 160m S com.maxmpz.audioplayer

I/busybox ( 856): 840 0 2472 R logcat

I/busybox ( 856): 847 0 744 S /system/bin/sh /system/bin/shutdown

I/busybox ( 856): 856 1007 664 S /system/bin/logwrapper busybox ps

I/busybox ( 856): 857 0 1164 R busybox ps

I/LSState ( 113): EventReceiver:android.intent.action.NOTIFICATION_ADD

I/echo ( 858): Trying unmount of /dev/block/mmcblk0p2

I//system/bin/umount( 860): failed.

I/logwrapper( 860): /system/bin/umount terminated by exit(1)

I/echo ( 862): Now phone is really shutting down

It's kind of obvious that a clean shutdown is not happening at this point.

I/echo ( 858): Trying unmount of /dev/block/mmcblk0p2

I//system/bin/umount( 860): failed.

Because you can see still many processes are running at the point where /usr/bin/shutdown.orig is called.

Immediately after this output above /usr/bin/shutdown.orig is called.

Hmm ... there must be another way ...

Basically the proper sequence which is needed (like standard linux shutdown) is something like:

sync + killall + unmount + shutdown

This should ensure no more processes are accessing the file system before shutdown.

I think I will take a look at what I can do with "shutdown.bravo.rc". Not sure about this though.