summaryrefslogtreecommitdiffstats
path: root/usr.sbin/apmd/apmd.c
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-06-22 05:34:45 +0000
committermdodd <mdodd@FreeBSD.org>2003-06-22 05:34:45 +0000
commit9e1cffe0692d16b27f8ce86102ece15af0bf7a9d (patch)
treea1026f0d68a1463ac3b2116b6ae3708b57f8e5e2 /usr.sbin/apmd/apmd.c
parentfa74d565f1d2449ff39d71733ad38e86bd7c66a0 (diff)
downloadFreeBSD-src-9e1cffe0692d16b27f8ce86102ece15af0bf7a9d.zip
FreeBSD-src-9e1cffe0692d16b27f8ce86102ece15af0bf7a9d.tar.gz
- Don't ignore SIGTERM.
- Add a command line switch to trigger POWERSTATECHANGE actions on un-reported power state changes. PR: i386/32251 Submitted by: Walter C. Pelissero <walter@pelissero.org>
Diffstat (limited to 'usr.sbin/apmd/apmd.c')
-rw-r--r--usr.sbin/apmd/apmd.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index a285b9b..88e755c 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -56,6 +56,7 @@ extern int yyparse(void);
int debug_level = 0;
int verbose = 0;
+int soft_power_state_change = 0;
const char *apmd_configfile = APMD_CONFIGFILE;
const char *apmd_pidfile = APMD_PIDFILE;
int apmctl_fd = -1, apmnorm_fd = -1;
@@ -71,7 +72,7 @@ struct event_config events[EVENT_MAX] = {
EVENT_CONFIG_INITIALIZER(NORMRESUME, 0)
EVENT_CONFIG_INITIALIZER(CRITRESUME, 0)
EVENT_CONFIG_INITIALIZER(BATTERYLOW, 0)
- EVENT_CONFIG_INITIALIZER(POWERSTATECHANGE, 0)
+ EVENT_CONFIG_INITIALIZER(POWERSTATECHANG, 0)
EVENT_CONFIG_INITIALIZER(UPDATETIME, 0)
EVENT_CONFIG_INITIALIZER(CRITSUSPEND, 1)
EVENT_CONFIG_INITIALIZER(USERSTANDBYREQ, 1)
@@ -476,7 +477,7 @@ proc_signal(int fd)
break;
case SIGTERM:
syslog(LOG_NOTICE, "going down on signal %d", sig);
- rc = 1;
+ rc = -1;
goto out;
case SIGCHLD:
wait_child();
@@ -515,6 +516,7 @@ check_battery()
{
static int first_time=1, last_state;
+ int status;
struct apm_info pw_info;
struct battery_watch_event *p;
@@ -548,6 +550,10 @@ check_battery()
* the event-caught state.
*/
if (last_state != AC_POWER_STATE) {
+ if (soft_power_state_change && fork() == 0) {
+ status = exec_event_cmd(&events[PMEV_POWERSTATECHANGE]);
+ exit(status);
+ }
last_state = AC_POWER_STATE;
for (p = battery_watch_list ; p!=NULL ; p = p -> next)
p->done = 0;
@@ -566,7 +572,6 @@ check_battery()
p -> level,
(p -> type == BATTERY_PERCENT)?"%":" minutes");
if (fork() == 0) {
- int status;
status = exec_run_cmd(p -> cmdlist);
exit(status);
}
@@ -642,7 +647,7 @@ main(int ac, char* av[])
char *prog;
int logopt = LOG_NDELAY | LOG_PID;
- while ((ch = getopt(ac, av, "df:v")) != EOF) {
+ while ((ch = getopt(ac, av, "df:sv")) != EOF) {
switch (ch) {
case 'd':
daemonize = 0;
@@ -651,6 +656,9 @@ main(int ac, char* av[])
case 'f':
apmd_configfile = optarg;
break;
+ case 's':
+ soft_power_state_change = 1;
+ break;
case 'v':
verbose = 1;
break;
OpenPOWER on IntegriCloud