To kill a LED (during shutdown)

This is a discussion on To kill a LED (during shutdown) within the Linux Programming forums, part of the Platform Specific Boards category; During system shutdown, what would be the best was to execute some code after the drives have been unmounted? The ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    1

    To kill a LED (during shutdown)

    During system shutdown, what would be the best was to execute some code after the drives have been unmounted?
    The system consists of a x86 system running Debian Linux from a CompactFlash. On the end product there will be no monitor so I need to disable a LED (simple I/O write) to indicate to the user that it is safe to power-down.
    My current train of thought is to write a daemon that loads at startup and does the I/O write at exit. But, being a linux noob, I'm not sure how to a) hook the system shutdown to the daemon or b) tie into the exit functionality within the daemon code.
    Any suggestions/comments?

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Your drives don't all get unmounted. Root gets REMOUNTED as read only. To that end, you'll still have access to everything you'll need. Next, you'll need to look at runlevels 0 and 6 (0 is for HALT and 6 is for reboot). Both of these have an associated /etc/{rc.d,init.d}/ file that executes as the system is going down. You could easily grep inside that directory to find each occurrence of umount or mount -oremount,ro to know where to put your line of bash code that would execute your software.

    Code:
    THE STUPID CODE TAGS SYSTEM DIDN'T LIKE ME TO USE {} SO I HAD TO PUT THIS IN

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I use signals sent from the kill() Linux call?
    By jsrig88 in forum C Programming
    Replies: 3
    Last Post: 10-10-2009, 10:20 PM
  2. Switch function problem
    By ahming in forum C Programming
    Replies: 3
    Last Post: 04-01-2008, 09:40 AM
  3. How to kill a dragon with various programming languages
    By g4j31a5 in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 10-01-2007, 12:13 PM
  4. Replies: 1
    Last Post: 08-11-2006, 05:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21