Code review / Monitoring battery

Phil Schulz ph.schulz at gmx.de
Tue Jul 13 06:52:09 PDT 2004


Hello!

  I wrote a little daemon which monitors the value of sysctl 
hw.acpi.battery.life and issues me two warnings before shutting down the 
machine in case of low battery. Since this is one of my first steps in 
Unix-programming, I wonder if anyone might take a minute or two to look 
over the code and comment on it. I put a lot of comments all over the 
place, especially where I'm unsure about how things work. The source 
code can be found at [1]. Please note that this 'server' is connected 
over an ADSL line with only 128kbps upstream just in case you wonder why 
it's so slow.
  Also I'd like to know if anyone knows something similar to this little 
tool. I found wmbattery from ports, but it doesn't shut down the 
computer. If there isn't such a program, I'd be happy to make this 
little thing a port (provided that there is need for it).

Thanks,

Phil.

[1] http://phil.homeunix.net:8000/battd.c


More information about the freebsd-hackers mailing list